Skip to content

Latest commit

 

History

History
103 lines (54 loc) · 1.82 KB

Lecture4.md

File metadata and controls

103 lines (54 loc) · 1.82 KB

SELECT AS FROM

;

Sample command - SELECT DOB AS "Date of Birth" FROM students2;

SELECT CONCAT ( <Column 1>,<Column 2>) AS FROM

;

Sample Command - SELECT CONCAT (Name,Section) AS Info FROM students2; SELECT CONCAT (Name,' ',Section) AS Info FROM students2; // add a space SELECT CONCAT (Name,' ',Section,' ', Score) AS Info FROM students2; // multiple columns SELECT CONCAT (Name,' ',Section,' ', Score) AS Info FROM students2 ORDER BY Info;

SELECT * FROM

AS ;

Sample Command -

SELECT * FROM students2 AS kids; SELECT * FROM students2 AS kids WHERE kids.Marital_status = "Single" AND kids.Score >80;

SELECT t2.Name,t2.Score FROM students2 AS t1, students2 AS t2 WHERE t1.DOB = t2.DOB AND t1.Name != t2.Name; // Self Join

SELECT DISTINCT FROM

;

Sample Command - SELECT DISTINCT Name FROM students2; SELECT DISTINCT DOB FROM students2;

SELECT DISTINCT , ... FROM

;

Sample Command - SELECT DISTINCT DOB, Score FROM students2;

SELECT COUNT() FROM

;

Sample Command - SELECT COUNT() FROM students2; SELECT COUNT() AS "Count of Students" FROM students2;

SELECT COUNT(*) FROM students2 WHERE Score >70 ;

SELECT SUM() FROM

;

Sample Command - SELECT SUM(Score) FROM students2;

//

SELECT AVG() FROM

WHERE {conditions...};

Sample command - SELECT AVG(Score) FROM students2;

//

SELECT MIN() FROM

;

Sample Command - SELECT MIN(Score) FROM students2;

//

SELECT MAX() FROM

;

Sample command - SELECT MAX(Score) FROM students2;

//

SELECT STDDEV() FROM

;

Sample Command - SELECT STDDEV(Score) FROM students2;