Concept explainers
“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.
“ORDER BY” Clause:
- User can sort the data in specific order using “ORDER BY” clause.
- The column on which to sort data is called a sort key or a simple key.
- To sort the output, use an “ORDER BY” clause followed by the sort key.
- If the user does not indicate a sort order, the output displayed in default order that is ascending order.
Example:
The example for “ORDER BY” clause is given below:
SELECT STUDENT_ID, STUDENT_NAME, STUDENT_CREDIT FROM STUDENT ORDER BY STUDENT_CREDIT;
The above query is used to list student ID, name and credit for each student with ascending order of student credit using an “ORDER BY” clause.
- From the given query, the sort key is “STUDENT_CREDIT”. So, the rows are sorted in ascending order by “STUDENT_CREDIT”.
“DESC” Operator:
- User can sort the data in descending order using a “DESC” operator.
- To sort in descending order, user follows the name of the sort key with the “DESC” operator.
Example:
The example for “DESC” operator is given below:
SELECT STUDENT_ID, STUDENT_NAME, STUDENT_CREDIT FROM STUDENT ORDER BY STUDENT_CREDIT DESC;
The above query is used to list student ID, name and credit for each student with descending order of student credit using an “ORDER BY” clause with “DESC” operator.
- From the given query, the sort key is “STUDENT_CREDIT”.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
A Guide to SQL
- Alter the given table by adding new column of "Job" in it and assign the sequence values to the column AS WELL. EMPLOYEE ID LAST NAME 149 Zotkey 174 Abel 176 Taylor ANNSAL HIRE_DATE 126000 29-JAN-00 132000 11-MAY-96 103200 24-MAR-98 NOTE: ASSUME 100 RECORDS IN THE TABLE. YOU NEED TO CREATE PROCEDURE FOR IT. USE ANY LOOP TO FILL THE ENTERIES ALONG WITH DML OPERATION.arrow_forwardProduce a list of all customer names in which the first letter of the first and last names is in uppercase and the rest are in lowercase. (refer to the tables in the JustLee Books database.)arrow_forwardWrite a SELECT statement to retrieve all columns from table EMPLOYEES only for records having a CITY column value of 'Central City'.arrow_forward
- Using the software.subscription table, pull all columns for subscriptions that have been cancelled. Use the results from the attachment to determine which column you need to filter on in your where clause. This is to write a query in a database.arrow_forwardOrder of tuples in a table is irrelevant, true or false?arrow_forwardList the trip name, trip id and customer number of all reservations for hiking trips. Sort the results in ascending order by trip id as the major sort key and customer number as the minor sort keyarrow_forward
- Task 6: Find the ID, first name, and last name of each customer for which an invoice was not created on November 15, 2021. Task 7: For each invoice, list the invoice number, invoice date, item ID, description, and category for each item that makes up the invoice.arrow_forwardGiven the table customers which contains columns customer_id, first name, last name, and state, and a table named addresses that contains columns address_id, customer id, state, city, zip, and street. Write a query that returns all customers last names with their state and zip. Assume that customer id in the addresses table is foreign key referencing customer_id in the customers table.arrow_forwardwhat is the necessary field in order table in access.arrow_forward
- Task 3: For each invoice, list the invoice number, invoice date, item ID, quantity ordered, and quoted price for each invoice line that makes up the invoice.arrow_forwardList the names of all Staff members who hold a faculty position and have a salary of $45,000 or less. Show their names as their first name, followed by a space, and then their last name but sort the list alphabetically by last name and then first name. Hint: Check out the Position column in the Staff table. All staff members who do not hold a faculty position will get a bonus this year equal to 5% of their salary. List the names, current salary, and bonus amount for each Staff member (non-faculty) who is due a bonus. Show your list in order with the person receiving the highest bonus first.arrow_forwardAdd two columns to the EMPLOYEES table. One column, named EmpDate, contains the date of employment for each employee, and its default value should be the system date. The second column, named EndDate, contains employees date of termination.arrow_forward
- 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 LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning