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 2000 Forums
 Transact-SQL (2000)
 Two Tables Distinct Distinct Field List

Author  Topic 

Jster
Starting Member

21 Posts

Posted - 2006-11-14 : 11:10:04
Been tasked with creating a sql statement that will return a list of distinct numbers. I'll try to illustrate it below
FirstTable SecondTable
ID ID
No No
Cent Cent

Actual Records
FirstTable SecondTable
10 1001 1 10 1001 1
10 1001 2 10 1001 2
10 1002 3 10 1002 3
10 1003 3 10 1003 3
10 1003 4

What I'm trying to get are all of the "Cent" fields. Basically the list below
Cent
---------
1
2
3
4

Any information would be appreciated.

Thanks,
Josh

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-11-14 : 11:13:00
select distinct cent from FirstTable



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-14 : 11:19:00
select cent from firsttable
union
select cent from secondtable


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Jster
Starting Member

21 Posts

Posted - 2006-11-14 : 11:22:08
Thank you, that worked.

Thanks,
Josh
Go to Top of Page
   

- Advertisement -