[SQL ] 關於一個子查詢

看板Database作者 (Arim5566)時間14年前 (2011/12/23 00:15), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
大家好 我是使用sql server 2008 想請問一個sql如下 select "team name" from (select player.[Team Name] ,SUM (cast(H as int)) as total from Score inner join Player on Score.[Player Name]=Player.[Player Name] inner join List on Player.[Team Name]=List.[Team Name] where League='Nations League' group by player.[Team Name]) as A where A.total=(select MAX(total) from A ) /*不懂為啥系統會說A是無效的物件*/ 因為我在from的地方已經建立了A 可是在where要用子查詢查A的時候,系統會說A是無效的物件... 我的schema是這樣子 player(player name,team name) score(player name,H) List(Team Name,League) 我的目的是要找出League='Nations League'而且H(安打)總和是最大的Team name 不知道為什麼會造成在where的子查詢沒辦法用到在from利用as建立的別名A 可是A.total是存在的呀~"~ 謝謝各位版友的指教 -- ~宅男的四個徵兆~ ∠□ ○ ! * \○/ ★    (○ ? ╦╦└□ " ○□═ □   □> ║║√√ ╦══╦ ∥    |\ 一回家就上PTT 每天想正妹 以當好人為樂 忘記正妹虧欠自己 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.32.197.57
文章代碼(AID): #1EyrUQQy (Database)
文章代碼(AID): #1EyrUQQy (Database)