Page 320 - IT 402 v2.0 class 10
P. 320
Select
A ‘SELECT’ statement retrieves zero or more rows from one or more database tables or database views. SELECT
is the most useful DML command. The ‘SELECT’ statement has many optional clauses:
specifies which rows to retrieve.
O specifies an order to return the rows.
To e ecute Select ueries:
Step 1: Click on the ‘Queries’ option available on the left side under database section.
Step 2: Click ‘Create Query in SQL View’ in the ‘Tasks’ section. A window appears on the screen.
Step 3: Type the query in this window and execute it by pressing the F5 function key or by clicking the
‘Execute’ icon in the window.
To retrie e dis la all t e data in a ta le:
S nta : SE L E CT * F RO M T AB L E NAM E ;
am le : To display all the data in the table:
SE L E CT * F RO M ST U D E NT ;
am le : To get details of the list of students whose LASTNAME is Kumar:
SE L E CT * F RO M ST U D E NT W H E RE L AST NAM E = ' K u mar ' ;
am le : To view the list of students in ascending order of MARKS:
SE L E CT * F RO M ST U D E NT O RD E R B Y M ARK S ASC;
We can use aggregate functions to:
Display the number of subjects or no of rows
SE L E CT CO U NT ( NO _ O F _ SU B ) F RO M ST U D E NT ;
Display Average of marks
SE L E CT AV G ( M ARK S) F RO M ST U D E NT ;
318 Touchpad Information Technology-X

