Home / CSE / SQL Basics :: section-1

CSE :: SQL Basics

  1. Find the name of those cities with temperature and condition whose condition is either sunny or cloudy but temperature must be greater than 70oF.

  2. A.

     SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' OR temperature > 70;

    B.

     SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition = 'cloudy' OR temperature > 70;

    C.

     SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' OR condition = 'cloudy' AND temperature > 70;

    D.

     SELECT city, temperature, condition FROM weather WHERE condition = 'sunny' AND condition = 'cloudy' AND temperature > 70;

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Find all the tuples having temperature greater than 'Paris'.

  4. A.

     SELECT * FROM weather WHERE temperature > (SELECT temperature FROM weather WHERE city = 'Paris')

    B.

     SELECT * FROM weather WHERE temperature > (SELECT * FROM weather WHERE city = 'Paris')

    C.

     SELECT * FROM weather WHERE temperature > (SELECT city FROM weather WHERE city = 'Paris')

    D.

     SELECT * FROM weather WHERE temperature > 'Paris' temperature

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Find all the cities with temperature, condition and humidity whose humidity is in the range of 63 to 79

  6. A.

     SELECT * FROM weather WHERE humidity IN (63 to 79)

    B.

     SELECT * FROM weather WHERE humidity NOT IN (63 AND 79)

    C.

     SELECT * FROM weather WHERE humidity BETWEEN 63 AND 79

    D.

     SELECT * FROM weather WHERE humidity NOT BETWEEN 63 AND 79

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Find the names of the countries whose condition is sunny.

  8. A.

     SELECT country FROM location WHERE condition = 'sunny';

    B.

     SELECT country FROM location WHERE city IN (SELECT city FROM weather WHERE condition = sunny');

    C.

     SELECT country FROM location WHERE city NOT IN (SELECT city FROM weather WHERE condition = 'sunny');

    D.

     SELECT country FROM location WHERE city UNION (SELECT city FROM weather WHERE condition = 'sunny');

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Find the name of all cities with their temperature, humidity and countries.

  10. A.

     SELECT city, temperature, humidity, country FROM location;

    B.

     SELECT weather.city, temperature, humidity, country FROM weather, location;

    C.

     SELECT weather.city, temperature, humidity, country FROM weather, location WHERE weather.city = location.city;

    D.

     SELECT weather.city, temperature, humidity FROM weather SELECT country FROM location WHERE weather.city = location.city;

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Find the name of cities with all entries whose temperature is in the range of 71 and 89

  12. A.

     SELECT * FROM weather WHERE temperature NOT IN (71 to 89);

    B.

     SELECT * FROM weather WHERE temperature NOT IN (71 and 89);

    C.

     SELECT * FROM weather WHERE temperature NOT BETWEEN 71 to 89;

    D.

     SELECT * FROM weather WHERE temperature BETWEEN 71 AND 89;

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which of the following query finds the names of the sailors who have reserved at least one boat?

  14. A.

     SELECT DISTINCT s.sname FROM sailors s, reserves r WHERE s.sid = r.sid;

    B.

     SELECT s.sname FROM sailors s, reserves r WHERE s.sid = r.sid;

    C.

     SELECT DISTINCT s.sname FROM sailors, reserves WHERE s.sid = r.sid;

    D.

     None of These

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following query finds colors of boats reserved by "Dustin"?

  16. A.

     SELECT DISTINCT b.color FROM boats b, sailors s WHERE s.sname = 'Dustin' AND s.sid = b.sid

    B.

     SELECT DISTINCT b.color FROM boats b, reserves r, sailors s WHERE s.sname = 'Dustin' AND s.sid = r.sid AND r.bid = b.bid;

    C.

     SELECT DISTINCT b.color FROM boats b, reserves r, sailors s WHERE s.sname = 'Dustin' AND s.sid = r.sid

    D.

     SELECT DISTINCT b.color FROM boats b, reserves r, sailors s WHERE s.sname = 'Dustin' AND r.bid = b.bid

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What does the following query find?
    (SELECT DISTINCT r.sid
    FROM boats b, reserves r
    WHERE b.bid = r.bid
    AND b.color = 'red')
    MINUS
    (SELECT DISTINCT r.sid
    FROM boats b, reserves r
    WHERE b.bid = r.bid
    AND b.color = 'green')

  18. A.

     Find the sailor IDs of all sailors who have reserved red boats but not green boats

    B.

     Find the sailor IDs of at least one sailor who have reserved red boats but not green boats

    C.

     Find the sailor Ids of atmost one sailor who have reserved red boats but not green boats

    D.

     None of These

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which of the following query finds the name of the sailors who have reserved at least two boats?

  20. A.

     SELECT DISTINCT s.sname FROM sailors s, reserves r1, reserves r2 WHERE s.sid = r1.sid AND r1.sid = r2.sid AND r1.bid ≠ r2.bid

    B.

     SELECT DISTINCT s.sname FROM sailors s, reserves r1, reserves r2 WHERE s.sid = r1.sid AND COUNT(r1.bid) > r2.bid

    C.

     SELECT DISTINCT s.sname FROM sailors s, reserves r1, reserves r2 WHERE s.sid = r1.sid AND r1.sid = r2.sid AND r1.bid <> r2.bid

    D.

     All of these

    View Answer

    Workspace

    Discuss Discuss in Forum