MySQL Forums
Forum List  »  Microsoft SQL Server

Re: How To Format A Query Output
Posted by: Soul Tech
Date: May 11, 2007 10:02AM


--declare @startdate datetime,
--@enddate datetime

select
RM.fldEditedBy as 'User Login',
case Grouping(RM.fldPriorityCode)
when 0 then RM.fldPriorityCode
else 'Total' end as 'Priority',
count(datediff(day,RM.fldRequestDate,RM.fldComCanDate)) as 'Calls Resolved'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldTrade = 'IT'
--and RM.fldRequestDate between '01-01-2007' and '08-05-2007'
and RM.fldRequestFlag like 'D'
and RM.fldRequestStatus = 'Y' 
group by RM.fldPriorityCode,RM.fldEditedBy with cube
union 
select
RM.fldEditedBy as 'User Login',
case Grouping(RM.fldPriorityCode)
when 0 then RM.fldPriorityCode
else 'Total' end as 'Priority',
count(datediff(day,RM.fldRequestDate,RM.fldComCanDate)) as 'Calls Resolved'
from tblRequestMaster RM
where RM.fldPriorityCode between 1 and 5
and RM.fldTrade = 'IT'
--and RM.fldRequestDate between '01-01-2007' and '08-05-2007'
and RM.fldRequestFlag like 'D'
and RM.fldRequestStatus = 'Y' 
group by RM.fldPriorityCode,RM.fldEditedBy with cube



Results;

NULL	1	73
NULL	2	2753
NULL	3	230
NULL	4	15
NULL	5	23
NULL	Total	3094
AMCCO039	1	9
AMCCO039	2	3
AMCCO039	Total	12
COBRI003	1	4
COBRI003	2	14
COBRI003	3	19
COBRI003	Total	37
JDONN001	1	2
JDONN001	2	954
JDONN001	3	31
JDONN001	Total	987
JFAIT001	1	9
JFAIT001	2	352
JFAIT001	3	28
JFAIT001	4	5
JFAIT001	5	20
JFAIT001	Total	414
MCATN001	1	23
MCATN001	2	930
MCATN001	3	53
MCATN001	4	4
MCATN001	Total	1010
PBRAD001	1	23
PBRAD001	2	119
PBRAD001	3	12
PBRAD001	4	2
PBRAD001	5	1
PBRAD001	Total	157
PHUDS001	1	3
PHUDS001	2	19
PHUDS001	3	30
PHUDS001	5	2
PHUDS001	Total	54
PKENN004	2	331
PKENN004	3	5
PKENN004	4	4
PKENN004	Total	340
PMISK001	2	31
PMISK001	3	52
PMISK001	Total	83

---------------------------------------
http://floetichoney.spaces.live.com/
---------------------------------------

Options: ReplyQuote


Subject
Written By
Posted
Re: How To Format A Query Output
May 11, 2007 10:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.