The document provides instructions to create a database called RYAN, a table called WORKERS with various attributes, and add sample data. It then lists 20 different SQL queries to write using operations like WHERE, ORDER BY, DISTINCT, JOINs, GROUP BY, and aggregate functions. It also provides 5 additional queries to write involving functions like COUNT, SUM, MIN, MAX and GROUP BY along with expected outputs.
The document provides instructions to create a database called RYAN, a table called WORKERS with various attributes, and add sample data. It then lists 20 different SQL queries to write using operations like WHERE, ORDER BY, DISTINCT, JOINs, GROUP BY, and aggregate functions. It also provides 5 additional queries to write involving functions like COUNT, SUM, MIN, MAX and GROUP BY along with expected outputs.
The document provides instructions to create a database called RYAN, a table called WORKERS with various attributes, and add sample data. It then lists 20 different SQL queries to write using operations like WHERE, ORDER BY, DISTINCT, JOINs, GROUP BY, and aggregate functions. It also provides 5 additional queries to write involving functions like COUNT, SUM, MIN, MAX and GROUP BY along with expected outputs.
Write commands and show outputs for the following :
CREATE A DATABASE RYAN .
CREATE A RELATION WORKERS . ATTRIBUTES ARE : WORKERID , NAME, GENDER , DOB, SALARY , ADDRESS , EMAILID , MOBILENUMBER . MAKE A PRIMARY KEY . IMPOSE NOT NULL CONSTRAINT ALSO ON FEW ATTRIBUTES. ADD DATA . NOW CREATE QUERIES BASED ON THE FOLLOWING : 1. SHOW STRUCTURE OF TABLE 2. WHERE WITH : (2 DIFFERENT QUERIES FOR EACH OPERATOR) A. > B. < C. = D. <> E. >= F. <= G. + H. – I. * J. / K. LIKE L. NOT LIKE M. IN N. NOT IN O. NULL P. NOT NULL Q. BETWEEN R. NOT BETWEEN 3. ORDER BY (BOTH ACS AND DESC) 4. DISTINCT ( 2 DIFFERENT EXAMPLES) 5. USE OF AND ( 3 QUERIES) 6. USE OF OR ( 3 QUERIES) 7. USE OF NOT ( 3 QUERIES) 8. UPDATE( 2 DIFFERENT EXAMPLES) 9. Putting text in a query( 2 DIFFERENT EXAMPLES) 10. aliasing( 2 DIFFERENT EXAMPLES) 11. DELETE( 3 QUERIES) 12. DROP TABLE 13. DROP DATABASE 14. alter table (add ,remove . MODIFY , CHANGE NAME OF an attribute) 15. ALTER TABLE (add and remove primary key) 16. Aggregate functions (max, min, avg, sum, count, count(*))( 6 DIFFERENT EXAMPLES) 17. group by( 2 DIFFERENT EXAMPLES) 18. Group by having clause( 2 DIFFERENT EXAMPLES) 19. Cartesian product on any two tables 20. equi-join 21. natural join 22. Union of two tables
Q2.
WRITE QUERIES AND THEIR OUTPUTS:
1. SELECT COUNT(*) FROM HOTEL;
2. SELECT COUNT(SALARY) FROM HOTEL;
3. SELECT SUM (SALARY) FROM HOTEL;
4. SELECT CATEGORY,COUNT(*) FROM HOTEL GROUP BY CATEGORY;
5. SELECT MIN(SALARY),MAX(SALARY),SUM(SALARY) FROM HOTEL;