in Databases retagged by
865 views
12 votes
12 votes

You are given a table named Alums that contains the names and personal information of all graduates of the college that you work for. It includes name and age attributes, and a state attribute specifying the state in which a person resides.

Consider the following SQL queries:

Query I

SELECT name, MIN(age)
FROM Alums
WHERE state = “CA”;

Query II

SELECT name, age
FROM Alums
WHERE state = “CA”
        AND age <= ALL (SELECT age FROM Alums
                        WHERE state = “CA”);

Query III

SELECT name, age
FROM Alums
WHERE state = “CA”
        AND age = (SELECT  MIN(age) FROM Alums);

Which of these queries would successfully find the name and age of the youngest graduate living in California (CA)?

  1. only II
  2. only III
  3. only I and II
  4. only II and III
in Databases retagged by
865 views

1 comment

Silly Mistake, Query 2nd  But Option 1 not Option 2.
I think the question setter knows where We will do mistake,

0
0

1 Answer

10 votes
10 votes

Option A : only II

asked query : find the name and age of the youngest graduate living in California (CA)

re framing : find the (name and age) of the youngest graduate living in CA among the all graduates living in CA [not in entire Table]

 

Query I

this would typically results in error, it’s lacking a GROUP BY clause REF

 

Query II

gives Correct result, California graduate and his age <= (minimum age in California) 

=== California Graduate and his age is minimum age in California

 

Query III

gives None,                           if the overall Alums minimum age < California’s minimum age

gives required result,           if the overall Alums minimum age >= California’s minimum age

therefore not always correct

edited by

2 Comments

you have completely miss understood my answer as well as the concept, I never said that ,

in fact I directly said “Query 1 results in error, since it’s lacking a GROUP BY clause “

you are selecting a column that isn’t grouped, i.e, “name”, please refer standard resources, this might help

2
2
Got u , thank you
0
0
Answer:

Related questions