0% found this document useful (0 votes)
27 views2 pages

Assigment 4

Uploaded by

yash sontakke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Assigment 4

Uploaded by

yash sontakke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Answer the given questions:

1. Examine these two rows from an employee table:


empid emp_name designation
------- ----------- -------------
12330 Scott Manager
10012 King CEO
Write a query to display the rows like this:
PROFILE
----------
Scott is a Manager
King is a CEO
Write your query here

SELECT
'PROFILE' AS PROFILE UNION ALL
SELECT emp_name || ' is a ' || designation AS PROFILE
FROM employee_table;

2. Write a query to Find out the total number of characters in the names of each customer
from the Customer table.
Write your query here
SELECT customer_name, LENGTH(customer_name) AS total_characters
FROM Customer;

3. Write a query to display the content of the customer table having customer names in
capital only.
Write your query here
SELECT *FROM Customer WHERE UPPER(customer_name) =
customer_name;

4. From the employees table(Employee_id, Name, Hire_date, Resignation_date)


Write a query to get the total number of days employees have worked in the
company(including the holidays as well).
Write your query here
SELECT Employee_id,Name,DATEDIFF(Resignation_date, Hire_date) + 1 AS
total_days_worked
FROM employees;
5. From the Employees table(employee_id,name,email,phone,salary), write a SQL
query to find those employees who earn above 35000 or the fifth character in
their phone number is 9.
Write your query here
SELECT *FROM Employees
WHERE salary > 35000 OR SUBSTR(phone, 5, 1) = '9';

6. The EMPLOYEE table has a column JOIN_DATE of data type DATE, containing
the date the employee joined the company.
Write a query to display details of employees where JOIN_DATE is within the last
24 months
Write your query here
SELECT *FROM EMPLOYEE
WHERE JOIN_DATE >= DATE_SUB(CURDATE(), INTERVAL 24 MONTH);

7. Write a query to get the details of all customers whose name starts with ‘an$’.
Write your query here
SELECT *FROM Customers
WHERE customer_name LIKE 'an%';
8. Write a query to get the round up salaries of each employee.
Write your query here
SELECT employee_id, name, CEIL(salary) AS rounded_salary
FROM Employees;

9. From the EMPLOYEES table, write a SQL query to find the employees who have
joined after 2018 Return first_name,join_date, salary.
Write your query here
SELECT first_name, join_date, salary FROM EMPLOYEES
WHERE join_date > '2018-01-01';

10. Write the correct syntax of to_char function


Write your query here
TO_CHAR(date_column, 'YYYY-MM-DD')

TO_CHAR(number_column, '9999.99')

You might also like