You are on page 1of 16

Data Warehousing

Assignment # 01
The purpose of this assignment is to understand following SQL queries syntax and the purpose.
You have to make a database of your choice in Access or SQL Server and run the following SQL
queries on it. The output of this assignment is a document containing the SQL queries plus the
screen shots of the output tables.

SQL Query has run in python interpreter using XAMPP server

1. Select
The SELECT statement is used to select data from a database.
2. Insert
The INSERT INTO statement is used to insert new records in a table.
3. Update
The UPDATE statement is used to modify the existing records in a table.

4. Delete
The DELETE statement is used to delete existing records in a table.
5. Distinct
The SELECT DISTINCT statement is used to return only distinct (different) values.
6. Where clause
The WHERE clause is used to filter records.
7. AND/OR
The AND and OR operators are used to filter records based on more than one condition:

 The AND operator displays a record if all the conditions separated by AND are TRUE.

 The OR operator displays a record if any of the conditions separated by OR is TRUE.

8. IN
The IN operator allows to specify multiple values in a WHERE clause.
9. ALIAS
SQL aliases are used to give a table, or a column in a table, a temporary name.

10. BETWEEN
The BETWEEN operator selects values within a given range. 
11. LIKE
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

There are two wildcards often used in conjunction with the LIKE operator:

 The percent sign (%) represents zero, one, or multiple characters

 The underscore sign (_) represents one, single character


12. COUNT
The COUNT() function returns the number of rows that matches a specified criterion

13. ORDER BY
The ORDER BY keyword is used to sort the result-set in ascending or descending order.

14. GROUP BY
The GROUP BY statement groups rows that have the same values into summary rows

The GROUP BY statement is often used with aggregate functions


(COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.
15. HAVING
The HAVING clause was added to SQL because the WHERE keyword cannot be used with aggregate
functions.

16. INNER JOIN


The INNER JOIN keyword selects records that have matching values in both tables.

17. LEFT OUTER JOIN


The LEFT JOIN keyword returns all records from the left table (table1), and the matching records from
the right table (table2). The result is 0 records from the right side, if there is no match.
18. RIGHT OUTER JOIN
The RIGHT JOIN keyword returns all records from the right table (table2), and the matching records
from the left table (table1). The result is 0 records from the left side, if there is no match.

19. FULL JOIN


The FULL OUTER JOIN keyword returns all records when there is a match in left (table1) or right
(table2) table records.
20. SELF JOIN
A self join is a regular join, but the table is joined with itself.

21. CREATE VIEW


In SQL, a view is a virtual table based on the result-set of an SQL statement.A view contains rows and
columns, just like a real table. The fields in a view are fields from one or more real tables in the database.
22. SQL ARITHMETIC FUNCTIONS—AVG, COUNT etc
The COUNT() function returns the number of rows that matches a specified criterion.

The AVG() function returns the average value of a numeric column. 


23. SQL STRING FUNCTIONS
ASCII: Returns the ASCII value for the specific character

CHAR Length: Returns the length of a string (in characters)

CONCATICATE: Adds two or more expressions together

TRIM: Removes leading and trailing spaces from a string

UPPER: Converts a string to upper-case

LOWER: Converts a string to lower-case


24. SQL UNION
The UNION operator is used to combine the result-set of two or more SELECT statements.

You might also like