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

SQLAssesment Questions

Uploaded by

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

SQLAssesment Questions

Uploaded by

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

1.

write a query to output the names of those students whose best friends got
offered a higher salary than them
SELECT s.Name FROM Students AS s
JOIN Packages AS sp ON s.ID = sp.ID
JOIN Friends AS f ON s.ID = f.ID
JOIN Packages AS fp ON f.Friend_ID = fp.ID
WHERE sp.Salary < fp.Salary
ORDER BY fp.Salary;

2.write a query to return the of customers not refreeed by the person with id 2
2. given a table customer_reference holding customer information and their
reference
Query:
select * from customer_reference where referee_id!=2;

3. Write a query identifying the type of each record in the TRIANGLES table using
its three side lengths. Output one of the following statements for each record in
the table:
Equilateral: It’s a triangle with 3 sides of equal length.
Isosceles: It’s a triangle with 2 sides of equal length.
Scalene: It’s a triangle with 3 sides of differing lengths.
Not a Triangle: The given values of A, B, and C don’t form a triangle.
Query:SELECT IF(A+B>C AND A+C>B AND B+C>A, IF(A=B AND B=C, 'Equilateral', IF(A=B OR
B=C OR A=C, 'Isosceles', 'Scalene')), 'Not A Triangle') FROM TRIANGLES;

4.write a query to list all the salesman and indicate those who do not have
customers in their cities, as well as those who have customer in their cities. Use
'UNION' concept.

5. seetha is a manager and she has asked to change the seating for a table of
employees. she has a table
Query:
SELECT IF(cnt % 2 = 1 AND id = cnt, id, IF(id % 2 = 1, id + 1, id - 1)) AS id,
student FROM seat,
(SELECT COUNT(*) AS cnt FROM seat) AS t
ORDER BY id;

6.The following tables consists of employee details. The company has closed one of
its department on 15 december 2019. find the employees who have been hired in the
last 60 days
Query:
select *,DATEDIFF("2019-12-2019",hireddate) as Different
from emp
where DATEDIFF("2019-12-2019",hireddate) between 0 and 60
order by hireddate ASC;

7.write an sql statement to find those salesman with all other information whose
name starts with sa
select * from Salesman where name like 'sa%';
8. the railway stations of a particular country which allows a certain number of
trains to pass through it in a day

You might also like