Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
want this select to work just like it is.. but only display the groups that have more that specified # of records... > 2 or whateverthanks
SELECT COUNT(a.ITEMDESC) AS Times_Billed, a.ITEMDESC, c.CUSTNAMEFROM dbo.BOA_SOP_Lines_vw AS a INNER JOIN dbo.BOA_SOP_HEADER_vw AS c ON a.SOPNUMBE = c.SOPNUMBEWHERE (c.CUSTNMBR IN ('1', '2', '3', '4', '5', '6', '7', '8'))GROUP BY a.ITEMDESC, c.CUSTNAMEORDER BY c.CUSTNAME
TG
Master Smack Fu Yak Hacker
6065 Posts
Posted - 2009-08-10 : 11:11:17
add a HAVING clause:where...group by ...HAVING count(*) > 2order by ...Be One with the OptimizerTG
cwfontan
Yak Posting Veteran
87 Posts
Posted - 2009-08-10 : 11:21:55
Great thanks!
quote:Originally posted by TG add a HAVING clause:where...group by ...HAVING count(*) > 2order by ...Be One with the OptimizerTG
bklr
Master Smack Fu Yak Hacker
1693 Posts
Posted - 2009-08-10 : 11:45:00
or try like thisselect * from (SELECT COUNT(a.ITEMDESC) AS Times_Billed, a.ITEMDESC, c.CUSTNAMEFROM dbo.BOA_SOP_Lines_vw AS a INNER JOIN dbo.BOA_SOP_HEADER_vw AS c ON a.SOPNUMBE = c.SOPNUMBEWHERE (c.CUSTNMBR IN ('1', '2', '3', '4', '5', '6', '7', '8'))GROUP BY a.ITEMDESC, c.CUSTNAME)where Times_Billed > 2