SQL means Structured Query Language and it is a standard language which is used for storing and manipulating the data in databases. In this tutorial we will learn some of the basic SQL queries used in data validation.
Table Name – employee
- for selecting all the data from the table -
select * from tablename
- Find the total number of records in a table-
Select count (*) from emp where age >40
- How to get the results of a Query sorted in any order?
SELECT empname, age, city FROM emptable ORDER BY empname
- To get the distinct entries from a table-
SELECT DISTINCT empname FROM emptable
- Compare a part of the name rather than the entire name-
SELECT * FROM people WHERE empname LIKE '%ab%'
- select first 5 records from a table-
select top 5 * from em
- Select all record from emp where job not in SALESMAN or CLERK.
select * from emp where job not in ('SALESMAN','CLERK');
- records where ename starts with ‘S’ and its lenth is 6 char.
select * from emp where ename like'S____';
- Records where ename may be any no of character but it should end with ‘R’
select * from emp where ename like'%R';
- fetch monthly salary of each and every employee?
select ename,sal/12 as monthlysal from emp;