A Guide to SQL
9th Edition
ISBN: 9781111527273
Author: Philip J. Pratt
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 15SCG
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.
“IN” Clause:
- The “IN” clause consists of an “IN” operator followed by a set of values.
- Using an “IN” clause, user can determine whether a column contains one of a particular group of values.
Example:
The example for “IN” clause is given below:
SELECT STUDENT_ID, STUDENT_NAME, STUDENT_CREDIT FROM STUDENT WHERE STUDENT_CREDIT IN(50, 70, 100);
The above query is used to list student ID, name, and credit for each student with a credit limit of “50”, “70” or “100”.
- From the given query, user can determine whether a student credit limit is “50”, “70” or “100” using an “IN” operator.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
with it, paste your code in a text file named Student.txt and save it in your
task folder.
Write the SQL code to create a table called Student. The table structure is
summarised in the table below (Note that STU_NUM is the primary key):
STU_NUM
Attribute Name
STU_SNAME
STU_FNAME
STU_INITIAL
STU_STARTDATE
COURSE_CODE
PROJ_NUM
STU STU_S STU_F STU_INITIAL
NUM NAME NAME
01
02
Snow John
E
CHAR(6)
After you have created the table in question 1, write the SQL code to enter
the first two rows of the table as below:
Stark Arya с
VARCHAR(15)
VARCHAR(15)
CHAR(1)
DATE
CHAR(3)
INT(2)
Data Type
STU_STARTDATE COURSE_ PROJ_
CODE
NUM
05-Apr-14
12-Jul-17
201
305
6
11
Assuming all the data in the Student table has been entered as shown
below, write the SQL code that will list all attributes for a COURSE_CODE of
305.
THIS MODULE IS ABOUT SUBQUERIES, SO YOU MUST USE SUBQUERIES INSTEAD OF TABLE JOINS
(a) From which two fields in which table can you calculate the enrollment of a section?(b) From which table can you get both course and section numbers?(c) Which field in table SECTION uniquely identifies a section, section id or section no?(d) Write a SQL statement to show sections and their enrollment.(e) Write a SQL statement to show sections with enrollment greater than five. Display both course andsection numbers
Trigger please
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
Similar questions
- Task 1: The Finance team wants to calculate a VAT (8%) on the amount of the stay reservations in the database. However, the team wants to calculate the VAT after the discounts are applied on the prices. In addition, it is important to remember if there is no discount/offers, then the value is NULL in the TRAVELS table. Create a procedure called VATCalculator to calculate the VAT amount and return with the corresponding travel ID. In addition, execute the procedure to account for NULL values and send the respective result to the team. The VAT value should be rounded to 2 decimals. Create a procedure to calculate the VAT. 1 Make sure you are using the following format to change the delimiter for the procedure: DELIMITER $$-- statements --END $$DELIMITER ; Test QueryCALL VATCalculator() Expected Results TRAVEL_ID VAT 5001 1.24 5002 1.64 5003 0.99 5004 2.12 5005 0.89 5006 1.05 5007 0.30 5008 1.51 5009 1.08 5010 1.64arrow_forwardTask 1: The Finance team wants to calculate a VAT (8%) on the amount of the stay reservations in the database. However, the team wants to calculate the VAT after the discounts are applied on the prices. In addition, it is important to remember if there is no discount/offers, then the value is NULL in the TRAVELS table. Create a procedure called VATCalculator to calculate the VAT amount and return with the corresponding travel ID. In addition, execute the procedure to account for NULL values and send the respective result to the team. The VAT value should be rounded to 2 decimals. Remember to redefine the MYSQL delimiter (;) when creating the procedure. This will prevent the commands from executing separately. Create a procedure to calculate the VAT. Make sure you are using the following format to change the delimiter for the procedure: DELIMITER $$-- statements --END $$DELIMITER ; Test Query: CALL VATCalculator() Expected Results TRAVEL_ID VAT 5001 1.24 5002 1.64 5003 0.99…arrow_forwardGo to the w3schools website’s SQL browser IDE. This is where you canwrite and test your SQL code using their databases. Once you are happywith it, paste your code in a text file named Student.txt and save it in yourtask folder.● Write the SQL code to create a table called Student. The table structure issummarised in the table below (Note that STU_NUM is the primary key):Attribute Name Data TypeSTU_NUM CHAR(6)STU_SNAME VARCHAR(15)STU_FNAME VARCHAR(15)STU_INITIAL CHAR(1)STU_STARTDATE DATECOURSE_CODE CHAR(3)PROJ_NUM INT(2)● After you have created the table in question 1, write the SQL code to enterthe first two rows of the table as below:STU_NUMSTU_SNAMESTU_FNAMESTU_INITIALSTU_STARTDATECOURSE_CODEPROJ_NUM01 Snow John E 05-Apr-14 201 602 Stark Arya C 12-Jul-17 305 11● Assuming all the data in the Student table has been entered as shownbelow, write the SQL code that will list all attributes for a COURSE_CODE of305.…arrow_forward
- Write a SELECT statement that returns two columns basedon the EMPLOYEES table. Contact, is the employeelastname and the first initial of the first name. The secondcolumn, Phone, is the homephone without the area code.Only return rows for those employees in the 206 areacode, sort the results by the last name.arrow_forwardWrite the T-SQL scripts for the following tasks: Write a query to list the employees whose email is a Gmail account.arrow_forwardIn The SQL Oracle Application Using the UNION operator, write a query that displays the employee_id, job_id, and salary of ALL present and past employees. If a salary is not found, then just display a 0 (zero) in its place.arrow_forward
- In the same text file you created in step 2, add SQL commands to insert the sample records (given above) into the tables. In addition to those sample records, insert your name (you can make up the other info) into the table as a patient or a doctor. Write SELECT statements to display all records from the tables.arrow_forwardWrite the T-SQL scripts for the following tasks: Write a query to select the employees whose last name begins with "Pa" and ends with any sequence ofcharacters.arrow_forwardIn this module, it is assumed that students already have JLDB installed so they need to run JLDB_Build_9.sql to add the three tables to the existing DB. If you do not have it installed, you need to run JLDB_Build_8.sql first and then JLDB_Build_9.sql. Write a SQL code to join two tables using the WHERE statement. Explain what the query is intended to do in a complete, coherent sentence with no SQL terminology. Repeat Problem 1 above but remove the WHERE statement. What happened? Why? Write an SQL query to join three related tables using JOIN … ON in the JustLee Books. Select four-five columns that you would like to display in the output (do not use SELECT *). Include one condition with a special comparison operator. Explain what the query is intended to do in a complete, coherent sentence with no SQL terminology. Write an SQL query to join three related tables using JOIN … USING in the JustLee Books. Select four-five columns that you would like to display in the output (do not use…arrow_forward
- USE NORTHWIND DATABASE Write a SELECT statement using the CASE function. The statement returns two columns basedon how many orders the customer has in the database. The first column is the customer name andthe second column, Membership Type, is based on which case applies to the customer:If the customer has more than 25 orders they are a Diamond Customer.If the customer has more than 15 orders they are a Gold Customer.If the customer has more than 10 orders they are a Silver Customer.If the customer has more than 5 orders they are an Iron Customer.Otherwise the customer is a Valued Customer.arrow_forwardTask 4: The InstantRide Finance team also wants to analyze travels where more than the average discount rate is applied. They want to look for any correlation between higher discount amounts against other travel characteristics. You need to create a SELECT statement which is filtered with a subquery to calculate the AVG of the TRAVEL_DISCOUNT column. Task: Find all travels where an above average discount was applied. (SQL Database Test)arrow_forwardHow do I display the number of topics that have less than three Class Sessions and at the same time be able to display the number of topics that have less than three Class Sessions by using emulator table? This is SQL CITD 120.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
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
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
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning