Don't let the Lockdown slow you Down - Enroll Now and Get 3 Course at 24,999/- Only. Explore Now!

General

Select Statement in SQL

Select Statement in SQL

Select Statement in SQL

The select request against the database and is sent to the Oracle server. The results of each SELECT statement is sent back to the client. Each time a SELECT statement is executed, network traffic is generated. Hence, multiple SELECT statements result in multiple round-trip transmissions, adding significantly to the network traffic.

When Are these SELECT statements combined into the PL/SQL program, they are sent to the server as a single unit. The SELECT statements are the PL/SQL program are executed in the server. Therefore, a PL/SQL program encompassing multiple SELECT statements can be executed at the server and have the results returned to the client in one round trip.

The capabilities of the SELECT statement introduce the three fundamentals. Theoretical concepts of the projection, selection, and join.

Syntax

Select * from tablename;

Example:

Select Statement in SQL Example

Select a Particular Column in a Table

Syntax

select columnname1, columnname2 from table name;

Example:

Select a Particular Column

DISTINCT-SELECT

In its most primitive form, the SELECT statement supports the projection of columns and the creation of arithmetic, character, and date expressions. It also facilitates the elimination of duplicate values from the results set. The word “unique” should guide you to use the DISTINCT keyword. The selection includes the building In the SELECT clause and using by DISTINCT keyword to limit the rows returned.

Syntax

SELECT *|{[DISTINCT] column|expression [alias],...} FROM table;

 Example:

Distinct Select

Distinct Select Example

Order By

The named notation is a sequence that is part of the parameter name and value of the argument. The named notation method doesn’t consider the order. If you are using a mix notation before the positional we need to place named notation.

Syntax

Select columnname1, columnname2, column name(n)
From tablenmae
Order by columnname1, columnname2...ASC | DESC;

Order By Example-1
Order By Example-2

Into Clause

It is important to remember that the order of variables listed in the INTO clause must follow the order of columns listed in the SELECT statement In other words of  INTO clause listed is the variables to that v_zip and v_state it was misplaced while the SELECT statement remained unchanged, the scripts would generate.

Syntax

Merge (Insert + Update)

Example

Into Clause Example-1

Into Clause Example-2

Into Clause Example-3

Into Clause Example-4

HAVING CLAUSE:

Group functions are represented by the letter G followed by a number. The first simple form contains no nested functions. GROUP BY clause is mandatory since the average value of group items per group is calculated before being aggregated by the SUM function.

The group functions discussed earlier use groups of rows comprising the entire table. This section explores partitioning a set of data into groups using the GROUP BY clause. Group functions may be applied to these subsets or clusters of rows. The syntax

of group functions and the GROUP BY clause are discussed in the following areas:

  • Creating groups of data
  • The GROUP BY clause
  • Grouping by multiple columns

It is common to see the grouping attribute in the SELECT list alongside grouping functions. If an item, which is not a group function, appears in the SELECT list and If a GROUP BY clause is present but that item is not a grouping attribute.

Having Clause Example-1

Having Clause Example-2

Related Blogs

  1. SQL Joins
  2. Schema in SQL
  3. Decode in SQL
  4. CASE Statement in MySQL
  5. Normalization in SQL
  6. SQL ORDER BY Clause
  7. LIKE Operator in SQL
  8. SQL Views
  9. SQL Concatenate Function
  10. What are the Manipulation Functions in SQL
  11. Primary Key In SQL
  12. SQL DateTime
  13. SQL Functions
Scroll Up
Besant Technologies WhatsApp