Common Sql Queries Interview Questions 4

Common SQL Queries Interview Questions : While we have quite a good number of DBMS softwares in the industry, they all follow some standardization to bring a sense of uniformity of technology .This is the basic reason as to why inspite of so many dbms softwares such as oracle, sql server, db2,sybase and the much well known open source stuff mysql, they all hold the same language in place to perform various database related operations which is called Sequel and abbreviated as SQL. SQL stands for standard query language. Here in below post and quite a number of other database testing related post you will have ample exposure to how SQL queries make our database testing possible.

10. SQL CREATE VIEW Syntax

CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition

11. In a table how can one find all of the employees whose first name does not start with 'M' or 'A'.
SELECT EmployeeID, FirstName, LastName, HireDate, City FROM Employees
WHERE (FirstName NOT LIKE 'M%') AND (FirstName NOT LIKE 'A%')

12.Find the wine(s) sold for the highest 
Sells(bar, wine, price)

SELECT wine
FROM Sells
WHERE price >= ALL(
SELECT price
FROM Sells
);
wines(name, manf)


13.Find the wines that are the unique wine by their manufacturer
SELECT nameFROM wines w1
WHERE NOT EXISTS(
SELECT *
FROM wines
WHERE manf = w1.manf AND
name <> w1.name
);

14.Find the name and manufacturer of wines that  James like
wines (name, manf) Likes(drinker, wine)
SELECT *
FROM wines
WHERE name IN
(SELECT wine
FROM Likes
WHERE drinker = ‘James’
);

15.Find bars that serve Mike at the same price James
charges for Bille.
Sells(bar, wine, price)

SELECT bar
FROM Sells
WHERE wine = 'Mike' AND
price =
(SELECT price
FROM Sells
WHERE bar = 'James''s Bar' AND
wine = 'Bille'
);

16.Find pairs of wines by the same manufacturer.
Wines(name, manf)
SELECT w1.name, w2.name
FROM Wines w1, Wines w2
WHERE w1.manf = w2.manf AND
w1.name < w2.name;


17.Find the wines that the frequenters of James’s Bar
like.
Likes(drinker, wine)
Frequents(drinker, bar)
SELECT wine
FROM Frequents, Likes
WHERE bar = 'James''s Bar' AND
Frequents.drinker = Likes.drinker;

18.Find drinkers whose phone has exchange 555.
Drinkers(name, addr, phone)
SELECT name
FROM Drinkers
WHERE phone LIKE '%555- ';


19.Find the price James's Bar charges for Bille.
Sells(bar, wine, price)
SELECT price
FROM Sells
WHERE bar = 'James''s Bar' AND wine = 'Bille';

20. How to find out the 10th highest salary in SQL query?
Table - Tbl_Test_Salary 
Column - int_salary

select max(int_salary) 
from Tbl_Test_Salary 
where int_salary in(select top 10 int_Salary from Tbl_Test_Salary order by int_salary)

Browse for more Database Testing Related Posts 



Common Sql Queries Interview Questions 4
For more articles on Manual Testing Log On to Manual Testing Articles


Post a Comment

أحدث أقدم