I need help writing this query for Sql Server.
The table appears as:
GalleryImageID (primary key)
Total Raiting (bigint)
So there will be many images listed here with the same GalleryID, each with how many hits that image recieved and it's total raiting score.
I need 2 different queries. I want to know the overall top galleryid's based on hits. So it will have to go through, find all of the images for a single galleryid and add them up, do this for the several hundred thousand galleries that exist and then return the ones that have the top 10 or 20 or whatever.