0% found this document useful (0 votes)
23 views1 page

Assign 02

The document contains 11 SQL queries with different selection, filtering, ordering and string manipulation operations on sample tables like customers, students, departments and workers.
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)
23 views1 page

Assign 02

The document contains 11 SQL queries with different selection, filtering, ordering and string manipulation operations on sample tables like customers, students, departments and workers.
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/ 1

1.

Query to select Customers having gmail id

SELECT customer_id, customer_name FROM customers WHERE email_id LIKE '%@gmail.com';

2. Write a query to fetch Student and their Department Based on City If data is in different
tables namely student table and department table:

SELECT S.student_name, d.department_name FROM Student s INNER JOIN Department d ON


s.department_id = d.department_id WHERE s.city = 'Coimbatore'; If data is in the same table:
SELECT student_name, department_name from STUDENT where city = “ Vijayawada”;

3. Write an SQL query to fetch “FIRST_NAME” from Worker table in upper case

SELECT UPPER(FIRST_NAME) FROM Worker;

4. Write an SQL query to fetch unique values of DEPARTMENT from Worker table.

SELECT DISTINCT DEPARTMENT FROM Worker;

5. Write an SQL query to find the position of the alphabet (‘a’) in the first name column
‘Amitabh’ from Worker table.

SELECT CHARINDEX('a', 'Amitabh') as Position from Worker;

6. Write an SQL query to print the FIRST_NAME from Worker table after replacing ‘a’ with ‘A’.

SELECT REPLACE(FIRST_NAME,’a’,’A’) as “Replaced_first_name” from Worker;

7. Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME
Ascending.

SELECT * from Worker order by FIRST_NAME ASC;

8. Write an SQL query to print details for Workers with the first name as “Vipul” and “Satish”
from Worker table.

SELECT * from Worker where FIRST_NAME in (‘Vipul’,’Satish’);

9. Write an SQL query to print details of the Workers whose SALARY lies between 100000 and
500000.

SELECT * from Worker where SALARY between 100000 and 500000;

10. Write an SQL query to print details of the Workers who have joined in Feb’2014.

SELECT * from Worker where year(joining_date) = 2014 and month(joining_date) = 2;

11. Write an SQL query to fetch worker names with salaries >= 50000 and <= 100000.

SELECT name from Worker where salary >=50000 and salary <= 100000

You might also like