- 替換:
vs.VehicleStatus VehicleStatus
- 有了:
max(vs.VehicleStatus) VehicleStatus
我在這個新領域的善意所闡述的問題有所幫助。
錯誤:因爲它不是在聚合函數或GROUP BY子句中包含
過程sp_VRMS_VehicleRequest_getvehiclerequestsgrouped,第25行
列「VRMS_VehicleStatus.VehicleStatus」在選擇列表中無效。
存儲過程的查詢:
SELECT max([VehicleRequestID]) VehicleRequestID
,[AdminId]
,max([DesireCarTypeId]) DesireCarTypeId
,max([AssignCarTypeId]) AssignCarTypeId
,max([Source]) Source
,max([Destination]) Destination
,max([Landmark]) Landmark
,max([NumberOfPassenger]) NumberOfPassenger
,CASE WHEN max([PickUpTIme])= min([PickUpTIme]) THEN null ELSE max([PickUpTIme]) END PickUpTill
,min([PickUpTIme]) PickUpTIme
,[BookingDate]
,max([CarNumber]) CarNumber
,max([DriverName]) DriverName
,max([DriverMobile]) DriverMobile
,max([AllocationDate]) AllocationDate
,vs.VehicleStatus VehicleStatus
,max([Remarks]) Remarks
,max([CRFTRF]) CRFTRF
,max([CostCentreNo]) CostCentreNo
,max([DutyDetails]) DutyDetails
FROM
[dbo].[VRMS_VehicleRequest] As vr
INNER JOIN
VRMS_VehicleStatus as vs on vr.VehicleStatusID = vs.VehicleStatusID
GROUP BY
AdminId, Bookingdate