i JUST WANT TO KNOW IF cte's are used in sybase too...i knw that cte's used for sql server..but have no idea whether they are used for sybase...
If Cte's are not used for sybase, is there a any other method in sybase that it performs as CTE in sql server...??
i HAVE a query like ::
select CONVERT(VARCHAR(7)
, [startdatetime],111) AS [year-month]
, nm.nameLine1 AS CompanyName
, sum(datediff(hour, startdatetime, enddatetime)) as total
from srl
inner join sr on srl.ServiceRequestId = sr.ServiceRequestId
inner join Name nm
on (sr.clientCustomerId = nm.customerId
and nm.nameTypeId = 'OFICE')
where (startdatetime >= '08-01-2011 00:00:00.000'
and enddatetime <= '10-31-2011 00:00:00.000')
group by CompanyName, [year-month]
order by CompanyName, [year-month]
output of above query:
year-month CompanyName total
---------- ----------- -----------
2011/08 B 4
2011/09 B 7
2011/10 B 0
2011/08 E 167
2011/09 E 212
2011/10 E 131
2011/08 L 14
2011/09 L 23
2011/10 L 3
2011/08 O 18
2011/09 O 8
2011/10 O 7
2011/08 S 43
2011/09 S 60
2011/10 S 60
i want the totals to be displayed in output as :: (I want the output to be as follows)
year-month CompanyName total companytotals
---------- ----------- ----------- ---------------
2011/08 B 4
2011/09 B 7
2011/10 B 0 11
2011/08 E 167
2011/09 E 212
2011/10 E 131 510
2011/08 L 14
2011/09 L 23
2011/10 L 3 40
2011/08 O 18
2011/09 O 8
2011/10 O 7 33
2011/08 S 43
2011/09 S 60
2011/10 S 60 163
Is there any methods to do this...?
Thanks in advance..