Hello. I have two tables. One table has 3 rows, the other has 6 rows. Is it possible to join these two in a select statement so I only get 6 rows (each item listed one time) instead of 18 rows where each item from Tbl1 ties with each item in TBL2?
For example:
If I run:
I get 16 rows of data.
Is it possible to just get 6 rows where everything is represented once?
Like this:
recordid, name, quarter
7, KEMP MAUDE, NW
7, KEMP E R, SW
7, HAYDEN JOHN F, SE
7, NULL, NE
7, NULL, SWSW
7, NULL, SENW
For example:
Code:
create table #party (recordid int, name varchar(200))
insert into #party values(7, 'KEMP MAUDE')
insert into #party values(7, 'KEMP E R')
insert into #party values(7, 'HAYDEN JOHN F')
create table #quarter (recordid int, quarter varchar(200))
insert into #quarter values (7, 'NW')
insert into #quarter values (7, 'SW')
insert into #quarter values (7, 'SE')
insert into #quarter values (7, 'NE')
insert into #quarter values (7, 'SWSW')
insert into #quarter values (7, 'SENW')
If I run:
Code:
select #party.recordid, name, quarter
from #party
join #quarter on #quarter.recordid = #party.recordid
I get 16 rows of data.
Is it possible to just get 6 rows where everything is represented once?
Like this:
recordid, name, quarter
7, KEMP MAUDE, NW
7, KEMP E R, SW
7, HAYDEN JOHN F, SE
7, NULL, NE
7, NULL, SWSW
7, NULL, SENW