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
 General SQL Server Forums
 New to SQL Server Programming
 get the count of rows returned by sql query

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2011-08-15 : 17:37:24
Hi,
Can anyone tell me how can i get a count of the number of rows returned by this query?

Thanks in ancipation,
Mavericky

SELECT (SELECT MAX(ScheduleID)+1 FROM Schedule),0, T1.PName,'Active',GETDATE(),'12/12/2011', T1.HEValue1, T1.HEValue2, T1.HEValue3, T1.HEValue4, T1.HEValue5,
T1.HEValue6, T1.HEValue7, T1.HEValue8, T1.HEValue9, T1.HEValue10, T1.HEValue11, T1.HEValue12, T1.HEValue13, T1.HEValue14, T1.HEValue15, T1.HEValue16,
T1.HEValue17, T1.HEValue18, T1.HEValue19, T1.HEValue20, T1.HEValue21, T1.HEValue22, T1.HEValue23, T1.HEValue24,NULL
FROM
(
SELECT DISTINCT P.Name AS PName,W.Name,A.LoadKW,
HEValue1 = SUM (case when AP.MaxAttributeValue = 1 then AP.UtilizationFactor*A.LoadKW else null End) ,
HEValue2 = sum(case when AP.MaxAttributeValue = 2 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue3 = sum(case when AP.MaxAttributeValue = 3 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue4 = sum(case when AP.MaxAttributeValue = 4 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue5 = sum(case when AP.MaxAttributeValue = 5 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue6 = sum(case when AP.MaxAttributeValue = 6 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue7 = sum(case when AP.MaxAttributeValue = 7 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue8 = sum(case when AP.MaxAttributeValue = 8 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue9 = sum(case when AP.MaxAttributeValue = 9 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue10 = sum(case when AP.MaxAttributeValue = 10 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue11 = sum(case when AP.MaxAttributeValue = 11 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue12 = sum(case when AP.MaxAttributeValue = 12 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue13 = sum(case when AP.MaxAttributeValue = 13 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue14 = sum(case when AP.MaxAttributeValue = 14 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue15 = sum(case when AP.MaxAttributeValue = 15 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue16 = sum(case when AP.MaxAttributeValue = 16 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue17 = sum(case when AP.MaxAttributeValue = 17 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue18 = sum(case when AP.MaxAttributeValue = 18 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue19 = sum(case when AP.MaxAttributeValue = 19 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue20 = sum(case when AP.MaxAttributeValue = 20 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue21 = sum(case when AP.MaxAttributeValue = 21 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue22 = sum(case when AP.MaxAttributeValue = 22 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue23 = sum(case when AP.MaxAttributeValue = 23 then AP.UtilizationFactor*A.LoadKW ELSE NULL End) ,
HEValue24 = sum(case when AP.MaxAttributeValue = 24 then AP.UtilizationFactor*A.LoadKW ELSE NULL End)
FROM Program P
INNER JOIN WholesaleProduct W
ON P.WholesaleProductID = W.ID
INNER JOIN AssetType AT
ON AT.ID = P.AssetTypeID
INNER JOIN AssetProfile AP
ON AT.ID = AP.AssetTypeID
INNER JOIN Asset A
ON A.AssetTypeID = AT.ID
GROUP BY P.Name,W.Name,A.LoadKW) T1

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-08-15 : 17:54:00
Kindly don't duplicate the post. As this will be a new start again for the experts (I am not) to understand and help.

Cheers
MIK
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-08-15 : 18:06:01
Dupe here:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=164305
Go to Top of Page
   

- Advertisement -