Home » SQL & PL/SQL » SQL & PL/SQL » Too many results
Too many results [message #648774] Thu, 03 March 2016 04:44 Go to next message
pretoriaan1971
Messages: 1
Registered: March 2016
Location: Belgium
Junior Member
Hello,
I have 2 tables. 1 containing cars and a second containing users of those cars.
The following query combines the 2 tables in order to see who's been using which car.

SELECT Cars.CarID, Cars.Make, Cars.Model, OwnerCar.Owner
FROM Cars
INNER JOIN OwnerCar ON Cars.CarID = OwnerCar.CarID

1 OPEL Combo Peeters
2 OPEL Combo Verbruggen
2 OPEL Combo Hollewegens
3 OPEL Insigna DeBrabandere

Now my problem is that for car 2 I get all the users and I only want to see the person who was the last user (in this case Hollewegens).

Can anybody point me in the right direction please.

Thank you.

Re: Too many results [message #648775 is a reply to message #648774] Thu, 03 March 2016 04:48 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals, as solution depends on it.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.


How can you know which one is the last one?

Previous Topic: end-of-file on communication channel
Next Topic: v$session
Goto Forum:
  


Current Time: Fri Mar 29 09:49:47 CDT 2024