Jump to content

have " sum, count, group by " in 1 query


poe

Recommended Posts

i have a table that look like this :

 

LID HIT MTH TYPE

111 2 200712 R

222 2 200712 R

111 1 200712 R

222 1 200812 R

333 5 200812 R

444 1 200812 R

555 3 200812 R

111 2 200812 R

111 6 200904 F

444 1 200904 R

333 1 200904 F

111 5 200907 R

222 5 200907 R

 

i want to count the number of links that:

MTH > 200712

MTH < 200907

TYPE = 'R'

SUM(HIT) > 3

 

so far i have

 

SELECT * , sum(`HIT`) AS `TTL`

FROM `STATS`

WHERE `MTH` > 200712

AND `MTH` <= 200907

AND `TYPE` = 'R'

AND `TTL` >3

GROUP BY `LID`

 

now i am stuck !

Link to comment
https://forums.phpfreaks.com/topic/167912-have-sum-count-group-by-in-1-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.