MySQL Forums
Forum List  »  Microsoft SQL Server

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

My code is now looking like this [I'm almost getting there] ::::




--Number of calls resolved by each staff member [for a specified date range]


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

select
RM.fldEditedBy as 'User Login',
RM.fldPriorityCode 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',
RM.fldPriorityCode 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	NULL	3094
NULL	1	73
NULL	2	2753
NULL	3	230
NULL	4	15
NULL	5	23
AMCCO039	NULL	12
AMCCO039	1	9
AMCCO039	2	3
COBRI003	NULL	37
COBRI003	1	4
COBRI003	2	14
COBRI003	3	19
JDONN001	NULL	987
JDONN001	1	2
JDONN001	2	954
JDONN001	3	31
JFAIT001	NULL	414
JFAIT001	1	9
JFAIT001	2	352
JFAIT001	3	28
JFAIT001	4	5
JFAIT001	5	20
MCATN001	NULL	1010
MCATN001	1	23
MCATN001	2	930
MCATN001	3	53
MCATN001	4	4
PBRAD001	NULL	157
PBRAD001	1	23
PBRAD001	2	119
PBRAD001	3	12
PBRAD001	4	2
PBRAD001	5	1
PHUDS001	NULL	54
PHUDS001	1	3
PHUDS001	2	19
PHUDS001	3	30
PHUDS001	5	2
PKENN004	NULL	340
PKENN004	2	331
PKENN004	3	5
PKENN004	4	4
PMISK001	NULL	83
PMISK001	2	31
PMISK001	3	52


Is there any way of naming the 'NULLs' at the following {to be 'Total' instead};

NULL 3094
NULL 12
NULL 37
NULL 987
NULL 414
NULL 1010
NULL 157
NULL 54
NULL 340
NULL 83

???


*NULL NULL 3094
NULL 1 73
NULL 2 2753
NULL 3 230
NULL 4 15
NULL 5 23
*can this be moved to here & how do I do that!?!
*AMCCO039 NULL 12
AMCCO039 1 9
AMCCO039 2 3
*the same again for this

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

Options: ReplyQuote


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


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.