Presentation is loading. Please wait.

Presentation is loading. Please wait.

Select. select Att 1, Att 2, Att 3,…, Att n from Tablename where (condition) Order by att1,att2 |desc; //Order By (Ascending & Descending) Explanation:

Similar presentations


Presentation on theme: "Select. select Att 1, Att 2, Att 3,…, Att n from Tablename where (condition) Order by att1,att2 |desc; //Order By (Ascending & Descending) Explanation:"— Presentation transcript:

1 select

2 select Att 1, Att 2, Att 3,…, Att n from Tablename where (condition) Order by att1,att2 |desc; //Order By (Ascending & Descending) Explanation: –condition will determine the row(s) which will be retrieved from the table. –If you want to select all the attributes from a table you can use all (*) operator.

3 Logical Operators NOT –Negation of the condition AND –The two conditions must be satisfied OR –The 1 st, the 2 nd or both of them must be satisfied

4 Logical Operation >, >=, between lowervalue and uppervalue –attribute/condition value lays in the closed interval [lowervalue,uppervalue] in (v 1,v 2,v 3, …, v n ) –attribute/condition value must match one value in the arches Like

5 select example select * from college; select Cid, Cname from college; select * from college where cid=10; select Cid, Cname from college where cid between 10 and 30; select Cid, Cname from college where cid in (10,30);

6 select from more than one table select T1.Att1, T1.Att2, T2.Att1,T2.Att2 from table1 T1, table2 T2 where (condition); Explanation: –Condition will determine which rows in the table1 related with table2

7 select example select T1.sid,T1.Sname, T2.cname from students T1, college T2 where T1.cid = T2.cid;

8 View benefits Create or replace view Std_view as select T1.sid,T1.Sname, T2.cname from students T1, college T2 where T1.cid = T2.cid;

9 Select from dual Select 1+3, sysdate from dual;

10 Alias Name Select att1 as “col-alias”, att2 as “col-alias”, att3 as “col-alias” From TableName Where (conditon) Order by att1 | col-alias; Notes: –As is optional. – “ ” bounded the column alias name is optional if your column alias name has no space, or special characters. –if the letter case is important.

11 Alias Name Select sid as “StudentID”, Sname “Student Name” From students Where sid >=20 Order by “StudentID”; --------------------------------------------------------------------- Note: –Use can use the alias name with the “order by” phrase. –You can’t use the alias name with the “where” phrase.

12 Aggregation Functions The aggregation function return number value and ignore the null values. –Count(att_name) –Sum(att_name) –Max(att_name) –Min(att_name) –Avg(att_name)

13 example Select count(saverage),sum(saverage), sum(saverage)/count(saverage), avg(saverage) from students; ------------------------ Select college.cid,cname, avg(saverage) from students,college where students.cid=college.cid group by college.cid,cname;

14 Select From Where Group by Having Order by

15 Select college.cid,cname, avg(saverage) from students,college where students.cid=college.cid group by college.cid,cname having avg(saverage)> 80;

16 select * from students where cid = (select cid from students where sid=12345);


Download ppt "Select. select Att 1, Att 2, Att 3,…, Att n from Tablename where (condition) Order by att1,att2 |desc; //Order By (Ascending & Descending) Explanation:"

Similar presentations


Ads by Google