Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Checking Sum of count is greater then certain numb

Author  Topic 

kamii47
Constraint Violating Yak Guru

353 Posts

Posted - 2015-02-23 : 00:48:44
I have a query
SELECT 
`TELCOID`, COUNT(*) smsCount
FROM `smsout`
WHERE `STATUS` = 'Send'
AND (RECEIVEDTIME BETWEEN DATE_SUB(NOW(), INTERVAL 1000000 MINUTE) AND NOW())
GROUP BY `TELCOID`


My result is
TELCOID smsCount
-10 7
-5 38
-4 1
-3 119
-1 3112
163 2
193 2

what i want to check if the Sum of all smscount is grreater then certain number [let's say 2000] then result comes other wise nothing
How can i do this

Kamran Shahid
Principle Engineer Development
(MCSD.Net,MCPD.net)

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2015-02-23 : 06:38:13
is this you wanted?
SELECT
`TELCOID`, COUNT(*) smsCount
FROM `smsout`
WHERE `STATUS` = 'Send'
AND (RECEIVEDTIME BETWEEN DATE_SUB(NOW(), INTERVAL 1000000 MINUTE) AND NOW())
GROUP BY `TELCOID`
having smsCount>2000

Javeed Ahmed
https://www.linkedin.com/pub/javeed-ahmed/25/5b/95
Go to Top of Page
   

- Advertisement -