CARS (cid, mid, cyear)
BUYERS (bid, bname, bcity, age)
MANUFACTURERS (maname, location)
MODELS (mid, maname, model)
SALESPEOPLE (sid, sname, years_employed)
TRANSACTIONS (bid, cid, sid, amount, month, day, year)
Print the sid of all salespeople who have sold at least one car of every manufacturer.
I do not know, i did it as - Wrong
Print the sname and total sales amount of the salesperson who had the highest total sales (in dollars) for 1997.
from salespeople s
join transactions t on t.sid = s.sid
join cars c on c.cid = t.cid
join models m on m.mid = c.mid
join manufacturers mn on mn.maname = m.maname
group by t.sid
having t.sid >= 1
and count (distinct m.maname) = count(distinct mn.maname);
Please help i tried my best...
select s.sname, to_char(sum(t.amount), 'fm$999999.00')
from transactions t, salespeople s
where t.sid = s.sid
group by s.sname, t.year
having (t.year = 1997) and max(sum(t.amount));