Question:
I’m trying to provide a SQL query to find whichXNumber
s had the most YNumber
s. Here is my data:1
s, which isn’t correct.Desired output would be a SELECT statement that answers the question: Which
XNumber
s had the most YNumber
s?Answer:
For each “Xnumber”, you want to count the “YNumber”, so just count “YNumber” and group by “Xnumber”.Since you only need the most “YNumber”s, use
RANK()
function.See db<>fiddle
If you have better answer, please add a comment about this, thank you!