Home » SQL & PL/SQL » SQL & PL/SQL » Putting Identification flag with query
Putting Identification flag with query [message #268541] Wed, 19 September 2007 01:08 Go to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

my query returns all selling and buying of my clients

query is like

select .......

UNION

select ......

where first query returns selling and second query returns buying.
i want to put my self a flag in query like S for selling and B for buying to identify buying and selling.. how to do this..
Re: Putting Identification flag with query [message #268544 is a reply to message #268541] Wed, 19 September 2007 01:12 Go to previous messageGo to next message
muzahid
Messages: 281
Registered: September 2004
Location: Dhaka, Bangladesh
Senior Member
Add one new column "shopping_type" each block
select col1, col2,..,coln, 'S' shopping_type from table
UNION
select col1, col2,..,coln, 'B' shopping_type from table
Re: Putting Identification flag with query [message #268548 is a reply to message #268544] Wed, 19 September 2007 01:23 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
UNION ALL

Regards
Michel
Re: Putting Identification flag with query [message #268600 is a reply to message #268548] Wed, 19 September 2007 02:44 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Good point - if you can guarantee that the two datasets are going to be different (which they will in this case as you've added a different string literal into each query) then using UNION ALL will mean that no DISTINCT needs to be performed on the combined resultset.
Previous Topic: BULK COLLECT
Next Topic: bulk collect
Goto Forum:
  


Current Time: Mon Dec 05 13:20:55 CST 2016

Total time taken to generate the page: 0.29995 seconds