| | |
outputting too many
Please support our Oracle advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2008
Posts: 108
Reputation:
Solved Threads: 1
I am just starting to learn sql and have to questions from my homework assignment.
The first is this:
Write a query which will project the average rental price and number of such videos for videos of Classic movies --- BUT! You must write this without explicitly using the category code for Classic movies; you must use the name 'Classic' in your query instead. Rename the columns to be "Avg Cost - Classic" and "# Videos - Classic", respectively, using precisely these spaces and case.
The code I wrote is:
But count is outputting a larger number then it is supposed to. I think it is counting all of the rentals, not just the ones labeled classic. But I am not sure how to fix this.
The second question is:
Using a join, (and NOT using ANY nesting or sub-selects), project the last names, first names, and date the video was due for clients who have ever rented the video with ID '130012'.
and my code is:
It is outputting more rows then it should, and outputs that all vid_id's are 130012. I think this has to do with the join, but am not sure how to do this without a join.
Thanks!
The first is this:
Write a query which will project the average rental price and number of such videos for videos of Classic movies --- BUT! You must write this without explicitly using the category code for Classic movies; you must use the name 'Classic' in your query instead. Rename the columns to be "Avg Cost - Classic" and "# Videos - Classic", respectively, using precisely these spaces and case.
The code I wrote is:
Oracle Syntax (Toggle Plain Text)
SELECT AVG(vid_rental_price) "Avg Cost - Classic", COUNT(*) "# Videos Classic" FROM movie_category, video WHERE movie_category.category_code = ( SELECT category_code FROM movie_category WHERE category_name = 'Classic' ) AND vid_rental_price < ( SELECT AVG(vid_rental_price) FROM video );
But count is outputting a larger number then it is supposed to. I think it is counting all of the rentals, not just the ones labeled classic. But I am not sure how to fix this.
The second question is:
Using a join, (and NOT using ANY nesting or sub-selects), project the last names, first names, and date the video was due for clients who have ever rented the video with ID '130012'.
and my code is:
Oracle Syntax (Toggle Plain Text)
prompt 2-5 SELECT DISTINCT client_lname, client_fname, date_due, vid_id FROM client, rental WHERE rental.vid_id = '130012';
Thanks!
![]() |
Similar Threads
- Why is my recursive function not outputting anything? (Python)
- Outputting to .csv: Returning to top of next column. (C++)
- Crossing fingers* Outputting to an outlook email (C++)
- numFactors - Counting Factors/Outputting Factors (Java)
- Passing arrays of objects to functions (C++)
- outputting *** where 3 is the int (Java)
- Cannot get method in project to work (Java)
- For the newbees (like myself) (C++)
- stuck with definition (C++)
Other Threads in the Oracle Forum
- Previous Thread: PL/SQL: ORA-00922: missing or invalid option
- Next Thread: Some explanation about isql *plus
| Thread Tools | Search this Thread |
2009predictions acquisition amazon.com bartz bernanke cia citrix cloudcomputing crm database dell economy enterprise enterprise2.0 enterprisesoftware federalreserve forbes hp ibm intellipedia internet larryellison layoffs linux loughridge mediawiki michaeljackson microsoft neverland nortel notebooks oil operatingsystem oracle palm rimm saas salesforce sap seagate socialcomputing sun sybase technologystocks virtualiron virtualization vmware wiki wikipedia xen yahoo zoho






