0
I need help
I need to run a sql query to " list all the cars that have been sold more than once". Tables Include: VEHICLE SALES PERSON SALES DETAILS CUSTOMER I have a feeling i need to use a DISTINCT command? I have tried the following SELECT v.make, sd.reg_no FROM vehicle v, salesdetail sd WHERE sd.reg_no = *sd.date_sold GROUP BY sd.date_sold; came up with multiple errors..... any ideas?
5 Answers
+ 1
Please provide the structure of the tables you need to query
+ 1
SELECT reg_no, COUNT(reg_no)
FROM salesdetail
HAVING COUNT(reg_no) >1
GROUP BY reg_no
ORDER BY COUNT(reg_no) DESC;
Thanx people i figured it out......đ
0
You can try to use inner join instead because I am not sure if you can write 2 tables directly after 'FROM'
SELECT v.make, sd.reg_no
FROM vehicle v
INNER JOIN salesdetail sd
ON (you should probably show how vehicle and salesdetail table are linked)
GROUP BY sd.date_sold;
Not sure if this will give you any syntax error though
0
How do you sell a car more than once? Perhaps something is inheritedly wrong with the question.
0
u can use "," after FROM for joining two tables with outer join