- WITH TEMP
- AS(
- SELECT
- YEAR(OrderDate) AS YEARS,
- shipvia,
- COUNT(ShipVia) AS SHIPCOUNT
- FROM Orders
- GROUP BY YEAR(OrderDate),ShipVia
- )
- SELECT t.YEARS
- FROM (
- SELECT
- YEARS
- ,MAX(SHIPCOUNT)
- FROM TEMP
- GROUP BY YEARS
- ) AS t
- JOIN TEMP t ON t.SHIPCOUNT = o.SHIPCOUNT
Q :
Msg 8155, Level 16, State 2, Line 18 No column name was specified for column 2 of 't'.
A:
他說你忘記加入別名 SHIPCOUNT = =+
參考
Q 寫TRIGGER 遇到
A: 結果就是欄位最大字數 小於insert to的字數
改掉insert into 超出的欄位數字即可
沒有留言:
張貼留言