Interview Question in Microsoft Transact-SQL


 

Interview Question :: Answer this t-sql query please


Tables:
MUSICIAN(musicianName, income, address, labelLicenseNumber)
LABEL(labelName, labelLicenseNumber, city, revenue)
ALBUM(albumName, musicianName, albumNumber, labelLicenseNumber, price, year)
SONG(songName, albumName, length, genre)
CONCERT(musicianName, cdate, place, city, price, capacity)



List the artist(s) who's cheapest album(s) is more or equally expensive than the most expensive album of some other artist.
Answers to "Answer this t-sql query please"
RE: Answer this t-sql query please?

SELECT a.albumName, a.musicianName FROM album a

WHERE a.albumNumber IN

(SELECT b.albumNumber FROM album b

GROUP BY b.musicianName

HAVING b.price = MIN(b.price))

AND a.price >=

(SELECT MAX(c.price) FROM album c

WHERE c.musicianName <> a.musicianName)



Of course, with two subselects (and one correlated to boot), it could well run really, really slowly...


 
Vote for this answer ::  
RE: Answer this t-sql query please?

That looks like homework.



You'll need INNER JOINS and WHERE conditions.



Make an attempt first, and I'll check back. *added to watchlist*
 
Vote for this answer ::  
Update Alert Setting