12. What are the SQL aggregate functions? 13. How do you avoid including duplicate values in a query's results? 14. What is a subquery?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Need help with this

CRITICAL
THINKING
Single-Table Queries
12. What are the SQL aggregate functions?
13. How do you avoid including duplicate values in a query's results?
14. What is a subquery?
15. How do you group data in an SQL query?
16. When grouping data in a query, how do you restrict the output to only those groups satisfy-
ing some condition?
17. How do you find rows in which a particular column contains a null value?
18. Use the Internet to research the SQL [charlist] wildcard that is available in Oracle and SQL
Server. Using the information you find, complete the following SQL command to find all cit-
ies that begin with the letters "C" or "G."
SELECT CUSTOMER_NAME, CITY
FROM CUSTOMER
WHERE CITY LIKE
Be sure to cite the URL(s) that provided the information.
129
Transcribed Image Text:CRITICAL THINKING Single-Table Queries 12. What are the SQL aggregate functions? 13. How do you avoid including duplicate values in a query's results? 14. What is a subquery? 15. How do you group data in an SQL query? 16. When grouping data in a query, how do you restrict the output to only those groups satisfy- ing some condition? 17. How do you find rows in which a particular column contains a null value? 18. Use the Internet to research the SQL [charlist] wildcard that is available in Oracle and SQL Server. Using the information you find, complete the following SQL command to find all cit- ies that begin with the letters "C" or "G." SELECT CUSTOMER_NAME, CITY FROM CUSTOMER WHERE CITY LIKE Be sure to cite the URL(s) that provided the information. 129
7. What wildcards are available in Oracle, and what do they represent?
8. How do you determine whether a column contains one of a particular set of values without
using an AND condition?
9. How do you sort data?
10. How do you sort data on more than one sort key? What is the more important key called?
What is the less important key called?
11. How do you sort data in descending order?
Transcribed Image Text:7. What wildcards are available in Oracle, and what do they represent? 8. How do you determine whether a column contains one of a particular set of values without using an AND condition? 9. How do you sort data? 10. How do you sort data on more than one sort key? What is the more important key called? What is the less important key called? 11. How do you sort data in descending order?
Expert Solution
Step 1: SQL Aggregate Functions:

What are the SQL aggregate functions?

=>           SQL (Structured Query Language) provides a set of aggregate functions that allow you to perform calculations on sets of rows in a database table.

=>           These aggregate functions summarize and return a single value from a group of multiple rows.

=>           Aggregate functions are often used in conjunction with the GROUP BY clause to perform calculations on groups of rows based on a specific column or columns. Here are some common SQL aggregate functions:

  1. COUNT():

    • Calculates the number of rows in a group.
    • Example: SELECT COUNT(*) FROM orders;
  2. SUM():

    • Calculates the sum of values in a numeric column.
    • Example: SELECT SUM(price) FROM products;
  3. AVG():

    • Calculates the average (mean) value of a numeric column.
    • Example: SELECT AVG(salary) FROM employees;
  4. MIN():

    • Retrieves the minimum value from a column.
    • Example: SELECT MIN(age) FROM customers;
  5. MAX():

    • Retrieves the maximum value from a column.
    • Example: SELECT MAX(score) FROM students;
  6. GROUP_CONCAT() (MySQL-specific):

    • Concatenates the values of a column into a single string, optionally separated by a delimiter.
    • Example (MySQL): SELECT GROUP_CONCAT(name ORDER BY score DESC SEPARATOR ', ') FROM students;
  7. STRING_AGG() (SQL Server-specific):

    • Concatenates the values of a column into a single string, optionally separated by a delimiter.
    • Example (SQL Server): SELECT STRING_AGG(product_name, ', ') FROM order_details;
  8. Variance (VAR) and Standard Deviation (STDDEV) (Database-specific):

    • Variance and standard deviation are aggregate functions used to measure the dispersion or spread of data.
    • Example (PostgreSQL): SELECT VARIANCE(sales_amount) FROM monthly_sales;
    • Example (Oracle): SELECT STDDEV(price) FROM products;
  9. FIRST() and LAST() (Database-specific):

    • These functions retrieve the first or last value in an ordered set.
    • Example (Oracle): SELECT FIRST_NAME, LAST_NAME FROM employees ORDER BY hire_date;
  10. Aggregate Functions with DISTINCT:

    • You can use the DISTINCT keyword with aggregate functions to apply them to unique values in a column.
    • Example: SELECT COUNT(DISTINCT category_id) FROM products;
  11. Aggregate Functions with GROUP BY:

    • Aggregate functions are often used in combination with the GROUP BY clause to calculate summary values for groups of rows based on one or more columns.
    • Example: SELECT department, AVG(salary) FROM employees GROUP BY department;
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY