php - How to count who has most hits in MySQL -


i have table column called bid , list how many records there exists each bid value.

kind of making top ten list.

example:

bid value 1 has 5 entries/rows. bid value 2 has 3 entries/rows. bid value 3 has 8 entries/rows. etc

how make query counts , sums each of bid's , sort in descending order?

thankful kind of help!

this should work in mysql

select u.firstname, t.bid, count(*) counts your_table t join users u on u.bid = t.bid t.confirmed <> '0000-00-00 00:00:00' group t.bid order counts desc 

generally can do

select u.firstname, t.bid, t.counts  (   select bid, count(*) counts   your_table    confirmed <> '0000-00-00 00:00:00'   group bid ) t join users u on u.bid = t.bid order t.counts desc 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -