Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 UNION operator problem

Author  Topic 

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-10-18 : 04:38:51
Hello All,
I have been facing a problem regarding UNIOIN.

I have a Query which is Selecting Amount from 2 different tables.
I want to show these two amounts as 2 different records.
So I used UNION operator and it worked fine
but there is an amount which is equal in both tables
UNION operator is showing only One Row for these records..

Data:
Table 1
ID Amount
1 20

Table 2
ID Amount
1 20

Query :

Select Amount From Table1
UNION
Select Amount From Table2

But it shows only one Row against this Query.

Can any one help me?????

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-10-18 : 04:54:41
Union eliminates duplicates. It concatenates the two row sets discarding duplicate rows (rows which are identical in the two rowsets)

If you want to see both rows, use UNION ALL

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -