Home » SQL & PL/SQL » SQL & PL/SQL » Grouping with Union statement (Oracle Sql)
Grouping with Union statement [message #332619] Wed, 09 July 2008 03:47 Go to next message
chuck1000
Messages: 5
Registered: July 2008
Junior Member
The attached script produces the following output:-

ready to List 30
Listed 50
Enquiries in Progress 20
Enquiries in Progress 30
Other statuses 60

Is there anyway to group the 2 entries for Enquiries in Progress so that it comes out once with a total of 50

cheers
  • Attachment: grouping.txt
    (Size: 1.20KB, Downloaded 128 times)
Re: Grouping with Union statement [message #332620 is a reply to message #332619] Wed, 09 July 2008 03:50 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
Always Post your test case.

Create table and insert statements.

Regards,
Rajat
Re: Grouping with Union statement [message #332624 is a reply to message #332620] Wed, 09 July 2008 03:55 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
I can't really guess what you have done in SQL statement.
Because no data is provided.

May be try to place an outer query on your query and calculate sum on 20,30.

Regards,
Rajat
Re: Grouping with Union statement [message #332625 is a reply to message #332619] Wed, 09 July 2008 03:56 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
SELECT column_1,sum(column_2)
from (union query)
GROUP BY column_1


You almost certainly want to use UNION ALL in that query.
Re: Grouping with Union statement [message #332631 is a reply to message #332625] Wed, 09 July 2008 04:10 Go to previous message
chuck1000
Messages: 5
Registered: July 2008
Junior Member
Thanks very much, union all worked
Previous Topic: error on get_wkt()
Next Topic: Generating a Sequence
Goto Forum:
  


Current Time: Fri Dec 09 11:42:36 CST 2016

Total time taken to generate the page: 0.14057 seconds