Select Query

Oracle, PL SQL, SQL Server,
Select statement can perform two types of job
  • Selection
  • Projection 
    • Column wise projection
    • Row wise projection

Selection

It means select all data from table and not apply any clause.
Ex:
 SELECT * FROM student;

Projection - Column wise Projection

Column restriction is a concept through which those many attributes are displayed which are mentioned in the select statement
Ex:
SELECT Name, Mobile
FROM student;

Projection - Row wise Projection

Row restriction is a concept through which those many records are displayed where condition is satisfied.
Ex:
SELECT Name, Mobile
FROM student
WHERE ID = 5;

Column Alias

Column alias is concept through which user can provide duplicate name to an existing column.
It can be given using three different methods

Type-1
 
SELECT Name Name, Mobile Mobile
FROM student;

Type-2
 
SELECT Name 'Name', Mobile 'Name'
FROM student;

Type-3
 
SELECT Name as 'Student Name', Mobile as 'Mobile Name'
FROM student;

Column Concatenation

Column concatenation is concept through which user can concatenation two or more ten two column to get a customised output.
Ex:
SELECT 'Name : '+ name+' Mobile number : '+mobile as Student from student;

Distinct

  • Distinct keyword is used in conjunction with Select statement to eliminate all the duplicate records.
  • It retrieve only unique records from table.
Ex:
SELECT DISTINCT * FROM student;

0 Comments