Top features of SELECT statement in SQL query
- Moreover, when a SELECT statement appears within another SELECT statement as a subquery, the inner SELECT statement returns a results table that serves as the input table for the outer (or main) SELECT statement.
If you are using a program (such as Visual Basic, C, or C++) to send a query (SELECT statement) to the DBMS, the DBMS will use a cursor to hold the tabular query results while it passes the rows of column values to your application program's (host) variables.
SELECT with WHERE clause
A SELECT statement with a WHERE clause will still return a table, but the results table will include only those rows from the input table(s) (list in the FROM clause) that satisfy the search condition in the WHERE clause. Thus, in the current example, the SELECT statement.SELECT employee_id, first_name, last_name, total_sales
FROM employees
WHERE first_name IS NULL
will display the results:
employee_id first_name last_name total_sales
================================
In the above result table, we have only headers and no rows. Since there is no matching row.
SELECT statement in aggregate function
When you use an aggregate function in a SELECT statement to display a single value, the SELECT statement still returns its result as a table.For example, based on the sample data in the current example's EMPLOYEES table, the SELECT statement
SELECT SUM(total_sales) FROM employees;
will return the table:
SUM(total_sales)
================
1072105.7900
Conclusion
- The SELECT statement is that it always produces a table. Moreover, because they are always returned in a table.
- you can store SELECT statement results back into the database as a table; combine the results of one SELECT statement with another to produce a larger, composite table
- use the results of one SELECT statement as the target (or input) table for another SELECT statement.
Comments
Post a Comment