This查詢位於ColdFusion中,並且它可以爲舊版本的ColdFusion運行,但無法運行這個查詢現在。因爲它不是在聚合函數或領域GROUP BY子句列XXXXX'在選擇列表中無效,因爲它不包含在聚合函數或GROUP BY子句中
<CFQUERY name="getUserList" datasource="#REQUEST.dsn#" maxrows="1">
SELECT
TUser.userID as user_ID,
Min(TUser.agencyID) as agencyID,
Min(TUser.servicing_EntityID) as servicing_EntityID,
Min(Tuser.userid) AS userID,
Min(Tuser.lastname) AS lastName,
Min(Tuser.firstname) AS firstName,
Min(Tuser.isSecondary) AS isSecondary,
Min(Tuser.corporate_ID) AS corporate_ID,
Min(Tuser.city) AS city,
Min(TUser.address1) AS address1,
Min(Corporate_Client.client_name) AS client_name,
Min(TLocationProvState.abrev) AS abrev,
TUser_Loyalty.loyalty_ID AS loyalty_ID
FROM TUser
LEFT JOIN TLocationProvState ON (Tuser.provinceID = TLocationProvState.PROVSTATEID)
LEFT JOIN Corporate_Client ON (Tuser.corporate_ID = Corporate_Client.client_ID)
LEFT JOIN TUser_Loyalty ON (Tuser.userid = TUser_Loyalty.userID)
LEFT JOIN TLoyalty ON (TUser_Loyalty.loyalty_ID = TLoyalty.loyalty_ID)
WHERE (0=1)
GROUP BY TUser.UserID, TUser_Loyalty.loyalty_ID
ORDER BY TUser.LastName, TUser.FirstName, TUser.User_ID
</CFQUERY>
將您的ORDER BY更改爲'ORDER BY LastName,firstName,User_ID',您將注意到您的選擇中有Min(LastName)和min(FirstName),這與Min的結果不同。由於表別名按順序可用,只需使用列別名即可。 – xQbert
試過....它沒有工作,仍然是同樣的錯誤。而現在的SQL是GROUP BY TUser.UserID,TUser_Loyalty.loyalty_ID,TUser.LastName,TUser.FirstName \t \t ORDER BY USER_ID,loyalty_ID,姓氏,名字 –
當我有奇怪的行爲,我只是不停地打破查詢...通過僅使用組中的TUser.userID,Tuser_Loyalty.Loyalty_ID來消除訂單,然後執行該操作?如果它運行,那麼順序是問題,我們集中在那裏,如果它仍然不運行消除分鐘和分組。它是否運行,然後在一分鐘內加回來,並通過... – xQbert