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.
“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.
“COUNT” function:
- It is the one function of aggregate function.
- The “COUNT” function is used to compute the number of rows in a table.
Example:
The example for “COUNT” function is given below:
SELECT COUNT(*) FROM STUDENT WHERE MARK_CREDIT >= 90;
The above query is used to display the number of students whose mark credit is greater or equal to “90” by using “COUNT” function.
- From the given query, the asterisk (*) represent any column.
- User can also count the number of rows in a query by selecting a particular column instead of using the asterisk.
- The below example is as follows
SELECT COUNT(STUDENT_ID) FROM STUDENT WHERE MARK_CREDIT >= 90;
- The below example is as follows
Trending nowThis is a popular solution!
Chapter 4 Solutions
A Guide to SQL
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr