A Guide to SQL
9th Edition
ISBN: 9781111527273
Author: Philip J. Pratt
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 4, Problem 18TD
Program Plan Intro
“SELECT” command:
The “SELECT” command is used to retrieve data in a
Syntax for selecting values from the table is as follows:
SELECT STUDENT_ID FROM STUDENT;
- The given query is used to display each student ID from “STUDENT” table.
Subquery:
- Subquery means one query is placed inside with another query.
- The inner query is called a subquery.
- The subquery is calculated first.
- After the subquery has been determined and the outer query can apply the results of the subquery.
Example:
The example for subquery is given below:
SELECT ORDER_NUMBER FROM ORDER_LINE WHERE BOOK_NUMBER IN(SELECT BOOK_NUMBER FROM BOOKS WHERE CATEGORY = 'CE');
The above query is used to list the order number using subquery.
- From the given query, the subquery is “(SELECT BOOK_NUMBER FROM BOOKS WHERE CATEGORY = 'CE')”.
- The subquery is computed first and then outer query is computed.
- The outer query retrieves the order number on every row in the “ORDER_LINE” table for which the book number is in the results of the subquery.
- Because that table contains only the book numbers in category “CE”, the results display the preferred list of order numbers.
- The outer query retrieves the order number on every row in the “ORDER_LINE” table for which the book number is in the results of the subquery.
“MIN” function:
- It is the one function of aggregate function.
- The “MIN” function is used to compute the minimum value in a column.
Example:
The example for “MIN” function is given below:
SELECT MIN(MARK_CREDIT) FROM STUDENT;
The above query is used to display the minimum mark credit from “STUDENT” table using “MIN” function.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Use a subquery to find employees' last names and hire date from the employees table whose manager is named "Hunold".
Show all name and phone numbers of students and the type of donation they received including any unmatched student.table name;StudentDonationVolunteer
If a subquery is used in the FROM clause of a query, how are the subquery’s results referenced in other clauses of the query?
Chapter 4 Solutions
A Guide to SQL
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - In which clause would you use a wildcard in a...Ch. 4 - Prob. 7RQCh. 4 - How do you determine whether a column contains one...Ch. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - How do you find rows in which a particular column...Ch. 4 - Use the Internet to research the SQL [charlist]...Ch. 4 - Prob. 1TDCh. 4 - Prob. 2TDCh. 4 - Prob. 3TDCh. 4 - Prob. 4TDCh. 4 - Prob. 5TDCh. 4 - Prob. 6TDCh. 4 - Prob. 7TDCh. 4 - Prob. 8TDCh. 4 - Prob. 9TDCh. 4 - Prob. 10TDCh. 4 - Prob. 11TDCh. 4 - Prob. 12TDCh. 4 - Prob. 13TDCh. 4 - Prob. 14TDCh. 4 - Prob. 15TDCh. 4 - Prob. 16TDCh. 4 - What is the price of the least expensive item in...Ch. 4 - Prob. 18TDCh. 4 - Prob. 19TDCh. 4 - Prob. 20TDCh. 4 - Prob. 21TDCh. 4 - Prob. 22TDCh. 4 - Prob. 23TDCh. 4 - Prob. 1CATCh. 4 - Prob. 2CATCh. 4 - Prob. 3CATCh. 4 - Prob. 4CATCh. 4 - Prob. 5CATCh. 4 - Prob. 6CATCh. 4 - Prob. 7CATCh. 4 - Prob. 8CATCh. 4 - Prob. 9CATCh. 4 - Prob. 10CATCh. 4 - Prob. 11CATCh. 4 - Prob. 12CATCh. 4 - Prob. 13CATCh. 4 - Prob. 14CATCh. 4 - Prob. 15CATCh. 4 - Prob. 16CATCh. 4 - Prob. 17CATCh. 4 - Prob. 18CATCh. 4 - Prob. 19CATCh. 4 - List the reservation ID and trip ID for all trips...Ch. 4 - Prob. 1SCGCh. 4 - Prob. 2SCGCh. 4 - Prob. 3SCGCh. 4 - Prob. 4SCGCh. 4 - Prob. 5SCGCh. 4 - Prob. 6SCGCh. 4 - Prob. 7SCGCh. 4 - Prob. 8SCGCh. 4 - Prob. 9SCGCh. 4 - Prob. 10SCGCh. 4 - Prob. 11SCGCh. 4 - Prob. 12SCGCh. 4 - Prob. 13SCGCh. 4 - Prob. 14SCGCh. 4 - Prob. 15SCGCh. 4 - Prob. 16SCG
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- List the item ID, description, and on-hand value for each item where on-hand value is at least $1,500. Assign the name ON_HAND_VALUE to the computed column.arrow_forwardYou will be using the Colonial Adventure Tours database. Find the trip ID and trip name for each trip whose maximum group size is greater than the maximum group size of at least one trip that has the type Biking.arrow_forwardList the owner number and last name for all owners located in the city of Seattle. Your query should ignore case. For example, a customer with the city Seattle should be included, as should customers whose city is SEATTLE, SEAttle, SeAttle, and so on. StayWell is offering a monthly discount for residents who pay their rent on a quarterly basis. The discount is 1.75 percent of the monthly fee. For each property, list the office number, address, owner number, owner’s last name, monthly rent, and discount as DISCOUNT. The discount should be rounded to the nearest dollar.arrow_forward
- 7. List all customers who were referred to the bookstore by another customer. List eachcustomer’s last name and the number of the customer who made the referral.arrow_forwardDisplay a list of all book titles and the percentage of markup for each book. The percentage of markup should be displayed as a whole number (that is, multiplied by 100) with no decimal position, followed by a percent sign (for example, .2793 = 28%). (The percentage of markup should reflect the difference between the retail and cost amounts as a percent of the cost. (refer to the tables in the JustLee Books database.)arrow_forwardYou will be using the Colonial Adventure Tours database. How many reservations include a trip price that is greater than $20 but less than $75?arrow_forward
- Find the rep number, last name, and first name of each sales rep who represents at least one customer with a credit limit of $10.000arrow_forwardTask 9: Use a subquery to find the sales rep ID, first name, and last name of each sales rep who represents at least one customer with a credit limit of $500. List each sales rep only once in the results. Task 10: Repeat Task 9, but this time do not use a subquery.arrow_forwardYou will be using the Colonial Adventure Tours database. List the trip IDs and trip names for each pair of trips that have the same start location.(You will need to assign an alias). The first trip id should be the major sort key, and the second trip id should be the minor sort key.arrow_forward
- For every order that has been received, display the order ID, the total dollar amount owed on that order (you’ll have to calculate this total from attributes in one or more tables; label this result TotalDue), and the amount received in payments on that order (assume that there is only one payment made on each order). To make this query a little simpler, you don’t have to include those orders for which no payment has yet been received. List the results in decreasing order of the difference between total due and amount paid.arrow_forwardFor every order that has been received, display the order ID, the total dollar amount owed on that order (you’ll have to calculate this total from attributes in one or more tables; label this result TotalDue), and the amount received in payments on that order (assume that there is only one payment made on each order). To make this query a little simpler, you don’t have to include those orders for which no payment has yet been received. List the results in decreasing order of the difference between total due and amount paid.arrow_forwardFor each order id, calculate the total of the Order. The total of an order is the sum of the prices of all the products (price*quantity) in that order. Sort the results in ascending order.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology PtrNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage