Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2009, 03:13 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default Group by

Hi,
I have a query written to fetch this details

SELECT FF.APPROVAL_LEVEL as APPLEVEL ,COUNT(CA.STATUS) as PROPOSALCASE,null as EXCEPTIONCASE
FROM SML_CA CA,SML_FP_FOLDER FF,SML_FP_FOLDER_DETAILS FFD
WHERE CA.STATUS in('APPROVED','DECLINED','RETURNED')
AND CA.REVIEW_BY_EXCEPTION is null
AND FF.APPROVAL_LEVEL is not null
AND FF.ID = FFD.FP_FOLDER_ID
AND FFD.FP_ID = CA.ID
GROUP BY FF.APPROVAL_LEVEL
UNION ALL
SELECT FF.APPROVAL_LEVEL as APPLEVEL,null as PROPOSALCASE,COUNT(CA.STATUS) as EXCEPTIONCASE
FROM SML_CA CA,SML_FP_FOLDER FF,SML_FP_FOLDER_DETAILS FFD
WHERE CA.STATUS in('APPROVED','DECLINED','RETURNED')
AND CA.REVIEW_BY_EXCEPTION ='Y'
AND FF.APPROVAL_LEVEL is not null
AND FF.ID = FFD.FP_FOLDER_ID
AND FFD.FP_ID = CA.ID
GROUP BY FF.APPROVAL_LEVEL
ORDER BY APPLEVEL DESC


the o/p of the above is
APPLEVEL
PROPOSALCASE
EXCEPTIONCASE
4
34

3
44

2
56

2

67
1
68

1

78





i want the o/p in this format



APPLEVEL
PROPOSALCASE
EXCEPTIONCASE
4
34

3
44

2
56
67
1
68
78






























Regards
Raj
 
Old February 17th, 2009, 03:14 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

the o/p of the above is


APPLEVEL
PROPOSALCASE
EXCEPTIONCASE
4
34

3
44

2
56

2

67
1
68

1

78





i want the o/p in this format





APPLEVEL
PROPOSALCASE
EXCEPTIONCASE
4
34

3
44

2
56
67
1
68
78
 
Old February 17th, 2009, 08:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Did you try put all of them in only one select???

Code:
SELECT FF.APPROVAL_LEVEL as APPLEVEL ,COUNT(CA.STATUS) as PROPOSALCASE,COUNT(CA.STATUS) as EXCEPTIONCASE
FROM SML_CA CA,SML_FP_FOLDER FF,SML_FP_FOLDER_DETAILS FFD
WHERE CA.STATUS in('APPROVED','DECLINED','RETURNED')
AND CA.REVIEW_BY_EXCEPTION is null 
AND FF.APPROVAL_LEVEL is not null
AND FF.ID = FFD.FP_FOLDER_ID
AND FFD.FP_ID = CA.ID
GROUP BY  FF.APPROVAL_LEVEL
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
The Following User Says Thank You to gbianchi For This Useful Post:
rajesh_css (February 18th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Group Within another Group, xslt1.0 jhansib4u BOOK: XSLT Programmer's Reference, 2nd Edition 4 November 22nd, 2007 01:24 AM
Restart new group number in Group Footer sukarso Crystal Reports 2 October 13th, 2006 12:11 PM
Group by , Sub Group by and Sum mateenmohd SQL Server 2000 1 March 29th, 2005 09:51 AM
GROUP BY... then sub group? mr.smith Classic ASP Basics 8 November 26th, 2003 09:40 PM
Group By andrekl SQL Server 2000 16 November 10th, 2003 11:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.