A Guide to SQL
A Guide to SQL
9th Edition
ISBN: 9781111527273
Author: Philip J. Pratt
Publisher: Course Technology Ptr
bartleby

Concept explainers

Question
Book Icon
Chapter 4, Problem 18CAT
Program Plan Intro

“SELECT” command:

The “SELECT” command is used to retrieve data in a database.

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.

“SUM” function:

  • It is the one function of aggregate function.
  • The “SUM” function is used to compute the total of the values in a column.

Example:

The example for “SUM” function is given below:

SELECT SUM(MARK_CREDIT) FROM STUDENT;

The above query is used to display the sum of all students mark credit from “STUDENT” table using “SUM” function.

“GROUP BY” Clause:

  • User can group the data using “GROUP BY” clause.
  • This clause allows the user to group data on a specific column and then computes statistics when user preferred.

Example:

The example for “GROUP BY” clause is given below:

SELECT CUSTOMER_NAME, SUM(AMOUNT) FROM CUSTOMERS GROUP BY CUSTOMER_NAME;

The above query is used to list the customer name and the sum of amount using “GROUP BY” clause.

“HAVING” Clause:

  • The “HAVING” clause is used to restrict the groups that are included.
    • This restriction does not apply to individual rows but relatively apply to groups.

Example:

The example for “HAVING” clause is given below:

SELECT STUDENT_ID, NAME, AGE, ADDRESS, TOTAL_MARK FROM STUDENTS GROUP BY AGE HAVING COUNT(AGE) >= 10;

  • The above query is used to display a record for a similar age count that would be more than or equal to “10”.

Blurred answer
Students have asked these similar questions
Note:- Do correct answer get upvote  Else downvoted
Write a SELECT statement that returns three columns: EmailAddress, OrderID, and the order total for each customer. To do this, you can group the result set by the EmailAddress and OrderID columns. In addition, you must calculate the order total from the columns in the OrderItems table. Write a second SELECT statement that uses the first SELECT statement in its FROM clause. The main query should return two columns: the customer�s email address and the largest order for that customer. To do this, you can group the result set by the EmailAddress column.
the employee table have the following . ask user what is the employee_id and how much employee wants to contribute 2 substitutions variable from end user &emp_id      &contribution_amount If employee salary is in between $1000-$3999 And if  employee's contribution amount is less than $100 then company match $100                   if  employee's contribution amount is greater than 100 but less than $200 then company match $75                  if  employee's contribution amount is greater than $200 then company match $50 $4000-$6999 And if  employee's contribution amount is less than $100 then company match $150                   if  employee's contribution amount is greater than 100 but less than $200 then company match $100                  if  employee's contribution amount is greater than $200 then company match $75  $7000-$12000And if  employee's contribution amount is less than $100 then company match $200                   if  employee's contribution amount is greater than…

Chapter 4 Solutions

A Guide to SQL

Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Text book image
Oracle 12c: SQL
Computer Science
ISBN:9781305251038
Author:Joan Casteel
Publisher:Cengage Learning
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning