If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Implementing Using SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-12-11, 08:06
ethio ethio is offline
Registered User
 
Join Date: Dec 2010
Posts: 9
Implementing Using SQL

Hi,
Im revising for an exam so I need someone to help me with two statements im having trouble with.

Q) Write a SQL statement to produce a list of all the vehicles which were rented out after the 17 September 2010 for a total rental cost of £120.
a)
SELECT car_license_no, car_make......rental_date_out
FROM rental
WHERE rental_date_out > '17-SEP-10'
AND total_sum = 120 ;

Q) Write a SQL statement to produce a list of the registration numbers of the vehicles which were collected before the 12 August 2010 along with the dates when they were returned. To this list, add the registration number of those vehicles which were never rented out.
a) really dont know....
Reply With Quote
  #2 (permalink)  
Old 05-12-11, 08:50
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
OK so first off develop your query using joins
MySQL :: MySQL 5.0 Reference Manual :: 12.2.8.1 JOIN Syntax
ignore the requirement for vehicles not rented out (for now)
you need to find a way to LIMIT the rows returned (y6ou only want one row per vehicle)
MySQL :: MySQL 5.5 Reference Manual :: 12.2.9 SELECT Syntax

then revisit the join syntax and find out which vehicles were rented
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 05-12-11, 10:28
Vinay007 Vinay007 is offline
Registered User
 
Join Date: May 2011
Posts: 11
give me tables and der fields..i will help u out..
Reply With Quote
  #4 (permalink)  
Old 05-14-11, 12:12
ethio ethio is offline
Registered User
 
Join Date: Dec 2010
Posts: 9
I dont understand, what would the join sysntax do? The columns I need are in one table so I wont need the join syntax?

SELECT car_license_no, rental_date_out, rental_date_returned
FROM rental
WHERE '12-AUG-2010'
[now I need to add vehicles which were never rented out] is this even possible? They cant be listed next to ^that^ statement because those are vehicles which were rented out.
Reply With Quote
  #5 (permalink)  
Old 05-17-11, 09:22
mathukumali mathukumali is offline
Registered User
 
Join Date: Jul 2010
Location: ISHHHH
Posts: 130
nice links
Quote:
Originally Posted by healdem View Post
OK so first off develop your query using joins
MySQL :: MySQL 5.0 Reference Manual :: 12.2.8.1 JOIN Syntax
ignore the requirement for vehicles not rented out (for now)
you need to find a way to LIMIT the rows returned (y6ou only want one row per vehicle)
MySQL :: MySQL 5.5 Reference Manual :: 12.2.9 SELECT Syntax

then revisit the join syntax and find out which vehicles were rented
__________________
WiTh Tnks & ReGaRdS
mAtHuKuMaLi
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On