Worksheet Week4
Worksheet Week4
Worksheet Week4
3. floor()
The FLOOR() function returns the largest integer value that is smaller than or equal to a number.
Ex: SELECT FLOOR(25.75);
4. mod(x,y)
The MOD() function returns the remainder of a number divided by another number.
Ex: SELECT MOD(18, 4);
5. pow(n,p)
The POW() function returns the value of a number raised to the power of another number.
Ex: SELECT POW(4, 2);
6. rand()
The RAND() function returns a random number between 0 (inclusive) and 1 (exclusive).
Ex: SELECT RAND();
7. round()
The ROUND() function rounds a number to a specified number of decimal places.
Ex: SELECT ROUND(135.375, 2);
8. sqrt()
The SQRT() function returns the square root of a number.
Ex: SELECT SQRT(64);
9. sin()
The SIN() function returns the sine of a number.
Ex: SELECT SIN(2);
205 06/94
Questions:
1. Display employee id, Firstname, LastName from employees of both USA and UK.
2. Display employee id, Firstname, LastName from employees who are working for both countries
US and UK.
3. Display details of Female HR employees of UK who are not working in USA.
4. Display IT employees of USA who are not working in UK.
5. Display HR employees who are working in both countries.
6. Display ALL employees of both Countries including duplicate values.
DCL Commands:
Data Control Language (DCL) is a subset of SQL commands used to control access to data in a database. DCL is
crucial for ensuring security and proper data management, especially in multi-user database environments. The
primary DCL commands in SQL include:
1. GRANT: This command is used to give users access privileges to the database. These privileges
can include the ability to select, insert, update, delete, and so on, over database objects like tables
and views.
• Syntax: GRANT privilege_name ON object_name TO user_name;
• For example, GRANT SELECT ON employees TO user123; gives user123 the
permission to read data from the employees table.
2. REVOKE: This command is used to remove previously granted access privileges from a user.
• Syntax: REVOKE privilege_name ON object_name FROM user_name;
• For example, REVOKE SELECT ON employees FROM user123; would
remove user123‘s permission to read data from the employees table.
DCL commands are typically used by database administrators. When using these commands, it’s important to
carefully manage who has access to what data, especially in environments where data sensitivity and user roles
vary significantly.