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)
 Distinct records

Author  Topic 

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2012-12-19 : 09:51:39
Hi

I have 2 tables having field month . I want to display distinct months from the 2 tables

Table1 Table2
11 11
12 12
1 1
2

So the query should return 11,12,1,2

Thanks

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-12-19 : 09:55:39
[code]SELECT [month] FROM Table1
UNION
SELECT [month] FROM Table2;[/code]
Go to Top of Page

sunny_10
Yak Posting Veteran

72 Posts

Posted - 2012-12-19 : 10:00:42
Hi

I don't need to use distinct keyword

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-19 : 10:04:15
where's distinct used in given suggestion?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -