我使用SQL Server 2008錯誤在SQL SELECT查詢的SQL Server 2008
我有,我想插入多行鍼對我的查詢是
insert into tbl select MAX(v.vehicle_id),3,v.category,150,v.rate
from vehicle v where v.parent_id=3 and v.category_id=0
我的選擇查詢表給錯誤
select MAX(v.vehicle_id),3,v.category,150,v.rate
from vehicle v where v.parent_id=3 and v.category_id=0
的錯誤是
Msg 8120, Level 16, State 1, Line 1
Column 'vehicle.category' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.
我該如何解決這個問題?
你有沒有嘗試使用GROUP BY? – MikkaRin