Aggregations and Group By Coding Practice

 


The database consists of

player_match_details
table that stores the information of players' details like name, match, score, year, number of fours and sixes scored.

This practice set helps you get well versed with GROUP BY and HAVING clauses. Let’s dive in!

namematchscorefourssixesyear
RamRR vs SRH62272011
JosephSRH vs CSK44242012
LokeshDC vs DD992132013
DavidSRH vs CSK961132014
JosephSRH vs CSK2012
VirajRCB vs RR53252010
ShyamMI vs RCB75292011
StarkMI vs DC75292012
StarkMI vs SRH2012
RamRR vs MI841112013
JosephSRH vs RR42142014
DavidSRH vs MI2014
RameshCSK vs RR9002010
RamRR vs DC75292011
JosephSRH vs MI30502012
LokeshDC vs RR872112013
RamRR vs SRH2011
DavidSRH vs MI9002014

1.

Get the total score of each player

Note: Output must contain rows in the descending order of

total_score

Expected Output Format:

nametotal_score
......

2.

Get the number of half centuries scored by each player.

Note: Output must contain rows in the descending order of

half_centuries

Expected Output Format:

namehalf_centuries
......

3.

Get the total number of 4's hit by each player as

no_of_fours
.

Note: Output must contain rows in the descending order of

no_of_fours

Expected Output Format:

nameno_of_fours
......

4.

Get the highest score of every player as

max_score
.

Note: Output must contain rows in the descending order of

max_score
of the player.

Expected Output Format:

namemax_score
......

5.

Get player

name
and the total number of matches played as
no_of_matches
by each player in the year 2012.

Note: Output must contain rows in the descending order of

no_of_matches
of each player.

Expected Output Format:

nameno_of_matches
......

6.

Get the year-wise performance, i.e.,

no_of_matches
and
runs_scored
by each player.

Note: Output must contain rows in the ascending order of

name
&
year

Expected Output Format:

nameyearno_of_matchesruns_scored
............

7.

Get

name
, average score of players as
avg_score
, and total number of sixes scored by the players as
total_sixes
whose average score is greater than 50.

Note: Output must contain rows in the ascending order of

name
of the player.

Expected Output Format:

nameavg_scoretotal_sixes
.........

8.

For each player who scored more than 50 in at least 2 matches, get the total number of matches where the players scored more than 50.

Note: Output must contain rows in the ascending order of

name
of the player.

Expected Output Format:

nameno_of_matches
......


 

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form