Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

kinda noobie question

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I have a DB that stores hits on pictures for a photo album. it stores IP, photoname, and datetime.

I want to make a SQL query to get back two columns, one the name each distinct photo, the other the number of tupples(or hits) that photo has. then I can calculate which photos are in the top 50% of hits and choose a pic of the week automatically.

I'm still pretty noobish with SQL and I can't get this query. anyone have a solution?
 
A starting point:
SELECT photoname, COUNT(*) Hits
FROM yourTable
GROUP BY photoname

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You might also be interested in TOP and ORDER BY.

SELECT TOP 100 photoname, sum(Hits) as Hits
FROM yourTable
GROUP BY photoname
ORDER BY sum(Hits) DESC
 
Thanks I got everything worked out now, I did something similar to TOP, I said DESC LIMIT 100 or whatever.

thanks guys
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top