sql - Using distinct keyword with join -
my professor has given me assignment.
write query produce snum values of salespeople (suppress duplicates) orders in orders table.
salespeople
snum number(4)
sname varchar2(10)
city varchar2(10)
comm number(3,2)
customer
cnum number(4)
cname varchar2(10)
city varchar2(10)
rating number(4)
snum number(4)
orders
onum number(4)
amt number(7,2)
odate date
cnum number(4)
snum number(4)
i not sure if have understood question completely.
i have written query using join.
select distinct s.snum,onum salespeople s, ordrs o s.snum = o.snum order snum;
and output is
snum onum ---------- ---------- 1001 3003 1001 3008 1001 3011 1002 3005 1002 3007 1002 3010 1004 3002 1007 3001 1007 3006
but don't want snum repeated. can point me in right direction ?
thanks.
the question asks "write query produce snum values of salespeople (suppress duplicates) orders in orders table" - doesn't specify need include order numbers. (it implies don't need order numbers, since including them duplicate snum values.)
given snum appears on orders table, should relatively simple select distinct list of snum values orders table.
Comments
Post a Comment