這裏是SQL益智挑戰你:SQL拼圖 - UNION ALL沒有UNION ALL
編寫一個查詢,將在三個不同的類別選擇前5名的記錄。
事情是這樣的:
select top 5 name, age from table1 where category = 22 order by age desc
union all
select top 5 name, age from table1 where category = 27 order by age desc
union all
select top 5 name, age from table1 where category = 53 order by age desc
但做到這一點不使用UNION或UNION ALL
如果您使用的是一些特定供應商的SQL擴展請註明您正在使用的數據庫。
和其他方式將三個子表加入到一個15條記錄'骨架' –
TOP 5是供應商特定的。 – Parfait
嗯......你說得對。 TOP 5是供應商特定的!哈哈!什麼停留在一個單一的數據庫一段時間可以做... – Anton