|
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,MaverickySELECT (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,NULLFROM(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 PINNER JOIN WholesaleProduct WON P.WholesaleProductID = W.IDINNER JOIN AssetType ATON AT.ID = P.AssetTypeIDINNER JOIN AssetProfile APON AT.ID = AP.AssetTypeIDINNER JOIN Asset AON A.AssetTypeID = AT.IDGROUP BY P.Name,W.Name,A.LoadKW) T1 |
|