BETWEEN CLAUSE-SQL QUERIES

  Day - 41 (27-03-2025)

 

Half day due to college placement .

 

 Day - 42 (27-03-2025)

 

BETWEEN CLAUSE:-

It display range data value

Q. Display student records between 102-104.

Ans. SELECT * FROM Student WHERE  roll BETWEEN 101 AND 204;

 

  ORDERBY CLAUSE:-

1. ASSCENDING ORDER:-

 SYNTAX= ASC  

2. DESSCENDING ORDER :-SYNT= DESC

EX:- SELECT * FROM Student  ORDER BY roll DESC; 

 

 

 GROUP BY CLAUSE :-

It is used to display similarly records at onces.

Ex :-SELECT name FROM Student GROUP BY name ;


 In clause :-

It is used to scearch mutliple data .

Ex.

SELECT * FROM Student WHERE name IN ('Riddhima','tuktuk');

 

 

Delete queries :-

The delete query cannot used without where clause .

Use only to delete the column in the  table .

Ex:-

DELETE FROM Student WHERE roll=101;

SELECT * FROM Student;

DELETE FROM Student WHERE name="SANTA"

 

 

 

Update query :-

It is used to update the data from the table .

Ex:-  UPDATE Student SET name ='Somesh' WHERE roll=202 OR roll=201;

SELECT * FROM Student;

  

  How to create duplicate table ?

Ans . For this we will use  :-

SELECT INTO QUERY

SYNTAX:-

SELECT * INTO NEWTABLENAME FROM OLDTABLENAME;

Ex:-SELECT * INTO Stubackup FROM Student;

SELECT * FROM Stubackup ;

 

Ø DATABASE LAS:-

1. DATABASE LAS IS used to change the column heading in the runtime

2. Keyword to use LAS IS   AS.

 

E x:-SELECT NAME AS 'Student Name' FROM Student;

 

 

 

Ø Change the Table Name - (Rename):-

Syntax:-

EXEC SP_RENAME ‘OLDTABLE NAME’ , ‘NEWTABLE NAME’ ;

Ex:-EXEC SP_RENAME 'Student' ,'newstudent';

 

Ø SQL FUNCTION/ SCALER FUNCTION.

1. SCALE FUNCTION ALWAYS USES WITH SELECT QUERY .

2. TYPE OF SCALE FUNCTION.

A. SUM()

B. AVG()

C. MIN()

D. MAX()

COUNT():-Synt=  SELECT  COUNT(roll) FROM newstudent;

E. TOP() 

Comments

Popular posts from this blog

ViewState for state management

Database joining

INTRODUCTION OF C#