SQL Commands
SQL Commands
SELECT *
SELECT used with an asterisk (*) will return all of the columns in the table we're
querying.
SELECT INTO
SELECT INTO copies the specified data from one table into another.
AS
AS renames a column or table with an alias that we can choose.
WHERE
WHERE filters your query to only return results that match a set condition.
We can use this together with conditional operators like =, >, <, >=, <=, etc.
OR
OR combines two or more conditions in a single query. Only one of the conditions
must be met for a result to be returned.
LIKE
LIKE searches for a specified pattern in a column. In the example code below, any row
with a name that included the characters Bob would be returned.
6)Display the employee name and annual salary for all employees.
7)Display the names of all the employees who are working in depart number 10.
8)Display the names of all the employees who are working as clerks and drawing a salary more than
3000.
9)Display the employee number and name who are earning comm.
10)Display the employee number and name who do not earn any comm.
IN
IN allows us to specify multiple values we want to select for when using the
WHERE command.
IS NULL
IS NULL will return only rows with a NULL value.
UPDATE
The UPDATE statement is used to update data in a table.
GROUP BY
The GROUP BY statement groups rows with the same values into summary
rows. The statement is often used with aggregate functions. For example,
the code below will display the average age for each name that appears in
our customers table.
ORDER BY
ORDER BY sets the order of the returned results. The order will be
ascending by default.
SELECT name FROM customers ORDER BY age;
DESC
DESC will return the results in descending order.
INNER JOIN
INNER JOIN selects records that have matching values in both tables.
RIGHT JOIN
RIGHT JOIN selects records from the right table that match records in the
left table.
EXISTS
EXISTS is used to test for the existence of any record in a subquery.
UNION
UNION combines multiple result-sets using two or more SELECT
statements and eliminates duplicate rows.
35)Display the total salary drawn by ANALYST working in depart number 40.
36)Display the names of the employee in order of salary i.e the name of the employee earning lowest
salary should salary appear first.
39)Display empno,ename,deptno,sal sort the output first base on name and within name by deptno and
with in deptno by sal.
40).The name of the employee earning highest annual salary should apper first.
11)display the names of employees who are working as clerks,salesman or analyst and drawing a
salary more than 3000.
13)Display the list of employcees who have joined the company before
30-JUN-90 or after 31-DEC-90.
19) Display the names of employees whose name starts with alphabet S.
20) Display the Employee names for employees whose name ends with Alphabet S.
LOREM IPSUM DOLOR SIT AMET, NUNC VIVERRA IMPERDIET PELLENTESQUE HABITANT
CONSECTETUER ADIPISCING ENIM. FUSCE EST. VIVAMUS A MORBI TRISTIQUE SENECTUS ET
ELIT. TELLUS. NETUS.