SOLVE

LATER

Game Time

Problem

Editorial

Analytics

Fredo is back again with an interesting activity for his class. Today, all students of his class are playing a game. Every student in the class has a unique roll number. Each student belongs to some house (Red/ Yellow/ Green/ Blue). The students are uniquely ranked in the game.

The student with rank $$i$$ gets $$(n+1-i)*100$$ points where $$n$$ is the total number of students in the class. Fredo wants to know the total points for each house and the best performing student's name for that house. Help him achieve the task.

Total points for any house is the sum of all students' points belonging to that house.Best performing student for any house is the student which earns the house most points.

**Note**: Output should contain the houses in ascending order of their names.

Table : **Students**

Field | Type |
---|---|

Name | text |

RollNo | int |

Table: **Positions**

Field | Type |
---|---|

RollNo | int |

Rank | int |

Table: **Houses**

Field | Type |
---|---|

HouseName | text |

RollNo | int |

Field | Type |
---|---|

HouseName | text |

Name | text |

Points | int |

**Sample Students Table:**

Name | RollNo |
---|---|

abc | 2013001 |

def | 2013002 |

ghi | 2013003 |

jkl | 2013004 |

**Sample Positions Table:**

RollNo | Rank |
---|---|

2013003 | 1 |

2013001 | 2 |

2013004 | 3 |

2013002 | 4 |

**Sample Houses Table**:

HouseName | RollNo |
---|---|

Yellow | 2013001 |

Blue | 2013002 |

Red | 2013003 |

Yellow | 2013004 |

HouseName | Name | Points |
---|---|---|

Blue | def | 100 |

Red | ghi | 400 |

Yellow | abc | 500 |

Time Limit:
5 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
MySQL,
PostgreSQL,
MSSQL,
Oracle Database

Initializing Code Editor...

{"a7a7d2e": "/pagelets/problems-hint/sql/houses/", "a7a7d11": "/pagelets/problem-author-tester/sql/houses/", "a7a7cf0": "/pagelets/suggested-problems/sql/houses/", "a7a7d4b": "/pagelets/recommended-problems/sql/houses/", "a7a7cb9": "/pagelets/show-submission/sql/houses/"}

{}

realtime.hackerearth.com

80

10641c33102f8fc62642d6cadc55d76846dbcb8d

58a29e5cae2309f04b28

/realtime/pusher/auth/