?????SQL????????????????÷???
???????????? ???????[ 2013/3/29 10:58:04 ] ????????
????????????????????????????????????????????????????????????????????????????????????????????????з?????????????????SQL???????????????????????????????????????Щ???????????????????????????????飬???????????????????????????????????????Books Online??
????1??????????????????
????????????????????????????????????????????С?SQL??ORDER BY????????????????????????????????????????????????????????????????????????????????????顣ORDER BY???????????????????????????
????2?????з?????????
???????????????????????????????????????м??????????????Χ?????????????????????????м????GROUP BY???????????????????????????磬?????????е?GROUP BY?????????????????????????????zip?????С?
SELECT ZIP FROM Customers GROUP BY ZIP
???????????GROUP BY??SELECT??乲????????Щ????????仰???SELECT?б????????GROUP BY?б?????????????????SELECT?б???????????????GROUP BY?????????t??????????????????GROUP BY??????????????????????????鰴????????????????У???????ORDER BY?????????GROUP BY????в???????????????????Ρ???????????????????????????????????????????С?
????3???????????????????
???????????????WHERE?????????GROUP BY???÷????е?????????磬???????????????????????ZIP?????С?
SELECT ZIP FROM CustomersWHEREState = 'KY' GROUP BY ZIP
??????????????WHERE???????GROUP BY???????????????????????GROUP BY????????WHERE????????????????
????4?????????з???
???????????WHERE???????????????????????????????????Щ?????????????鶨?嵫????????????????????????????????????С?????????????а???????????????????ALL????????WHERE???????????á????磬???????????????????ALL???????е?ZIP???飬???????????????????Щ??
SELECT ZIP FROM CustomersWHEREState = 'KY' GROUP BY ALL ZIP
????????????????????????????????????????????????ù????ALL????????t???????????????????ALL????????????????磬??????????????????????ZIP?е????????????????????????ZIP???
SELECT ZIP?? Count(ZIP) AS KYCustomersByZIP FROM
CustomersWHEREState = 'KY' GROUP BY ALL ZIP
??????????????????????е?????ZIP??????????????Щ???????????ZIP?????????(KYCustomersByZIP)???????0????????????GROUP BY ALL??
????5?????????????
????WHERE?????GROUP BY????????м??????????????????????????????????HAVING??????????£?WHERE????HAVING????????????????????????????????????????????????????????????????????????????WHERE?????????????HAVING????????顣
??????????????????HAVING???????????????????????顣???磬???????????????ZIP?????У???????????????????????????е?ZIP??
SELECT ZIP?? Count(ZIP) AS CustomersByZIP FROM
Customers GROUP BY ZIP HAVING Count(ZIP) = 1
?????????Щ?????λ???????????????С?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11