|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
sql query help needed
Hi all, I need some more help with a query joining data from two tables. What I want to do is to list the top film ordered.
I have an ordered table containing Customer ID and FilmID, this lists which customers have ordered what films. In the film table there is also Film ID along with title information. Example of customer id field data FILMid customerID 501 3 501 4 503 3 504 3 504 4 504 5 I just need to get the film name from the film table, add up the filmID which has been most wanted and output it so example output would be Harry Potter 5 Shrek 4 Ice Age 3 It needs to be ordered desc. Hope this is readable. Thanks in advance for the help. |
|
#2
|
||||
|
||||
|
try this
Code:
SELECT B.FilmName, COUNT(A.FilmID) As 'Number Ordered' FROM Customers As A INNER JOIN Films As B On (A.FilmID = B.FilmID) GROUP BY B.FilmName ORDER BY COUNT(A.FilmID) DESC |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > sql query help needed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|