Below is Sql Statement with Example provided. It will help SQL beginner more understanding about the usage of SQL statement. For more information about SQL Syntax, click here.
Name | Income | Company | Position |
Angle | 4500 | Ajax Tech Limited | Manager |
Helen | 6900 | Programmingschools Limited | CEO |
Micheal | 4000 | SQLTutorial Limited | DBA |
Nick | 5000 | Programmingschools Limited | Programmer |
SQL STATEMENT - Example Result with SQL Statement
Select All data from a table (same as above table)- SELECT * FROM TESTING
SELECT NAME,COMPANY FROM TESTING
name | company |
---|---|
Angle | Ajax Tech Limited |
Helen | Programmingschools Limited |
Micheal | SQLTutorial Limited |
Nick | Programmingschools Limited |
SELECT DISTINCT COMPANY FROM TESTING company Ajax Tech Limited Programmingschools Limited SQLTutorial Limited
SELECT COUNT(*) FROM TESTING
4 |
SELECT * FROM TESTING WHERE NAME='HELEN'
Name | Income | Company | Position |
---|---|---|---|
Helen | 6900 | Programmingschools Limited | CEO |
Name | Income | Company | Position |
---|---|---|---|
Helen | 6900 | Programmingschools Limited | CEO |
SELECT * FROM TESTING WHERE NAME='HELEN' OR COMPANY='Pragrammingschools Limited'
Name | Income | Company | Position |
---|---|---|---|
Helen | 6900 | Programmingschools Limited | CEO |
Nick | 5000 | Programmingschools Limited | Programmer |
SELECT * FROM TESTING WHERE COMPANY IN ('Pragrammingschools Limited')
Name | Income | Company | Position |
---|---|---|---|
Helen | 6900 | Programmingschools Limited | CEO |
Nick | 5000 | Programmingschools Limited | Programmer |
SELECT * FROM TESTING WHERE COMPANY LIKE '%PROGRAMMINGSCHOOLS%'
Name | Income | Company | Position |
---|---|---|---|
Helen | 6900 | Programmingschools Limited | CEO |
Nick | 5000 | Programmingschools Limited | Programmer |
Name | Income | Company | Position |
---|---|---|---|
Angle | 4500 | Ajax Tech Limited | Manager |
Helen | 6900 | Programmingschools Limited | CEO |
Nick | 5000 | Programmingschools Limited | Programmer |
Micheal | 4000 | SQLTutorial Limited | DBA |
SELECT * FROM TESTING WHERE ORDER BY COMPANY DESC Name Income Company Position Micheal 4000 SQLTutorial Limited DBA Helen 6900 Programmingschools Limited CEO Nick 5000 Programmingschools Limited Programmer Angle 4500 Ajax Tech Limited Manager
SELECT SUM(INCOME),COMPANY FROM TESTING GROUP BY COMPANY
SUM(Income) | Company |
---|---|
4500 | Ajax Tech Limited |
11900 | Programmingschools Limited |
4000 | SQLTutorial Limited |
SELECT COUNT(*),COMPANY FROM TESTING GROUP BY COMPANY
COUNT(*) | COMPANY |
---|---|
1 | Ajax Tech Limited |
2 | Programmingschools Limited |
1 | SQLTutorial Limited |
SELECT SUM(INCOME),COMPANY FROM TESTING GROUP BY COMPANY HAVING (SUM(INCOME)>5000)
SUM(INCOME) | COMPANY |
---|---|
11900 | Programmingschools Limited |
For Sql Update and Sql Delete statement, click here