2012-04-16 8 views
0

次のクエリは、MySQL 5上で動作しますが、私のクライアントは、MySQL 4.1.15があると、このクエリは次のエラーでチョーク:このMySQLクエリをMySQL 4.1.15で動作させるにはどうすればよいですか?

#1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

は、クライアントMySQLバージョンをアップグレードところでオプションではありません。誰かがMySqlの古いバージョンで動作するようにこれを書き直すのを助けることができますか?

SELECT 
    Sum(room_rev + room_rev_future) as weekly_room_rev, 
    Sum((`food_rev`) + (`beverage_rev`)) as weekly_catering_rev, 
    (SELECT min_sales_persons 
    FROM bdp_hotel_min WHERE 
    bdp_hotel_min.hotel_num = bdp_scorecard.hotel_num 
    AND UNIX_TIMESTAMP(bdp_hotel_min.`min_override_week`) 
    < UNIX_TIMESTAMP("2011-12-02 23:59:59") 
    ORDER BY bdp_hotel_min.`min_override_week` DESC LIMIT 1) as override_persons, 
    min_sales_persons 
FROM bdp_scorecard JOIN locations ON bdp_scorecard.hotel_num = locations.hotel_num 
WHERE bdp_scorecard.hotel_num =837 AND bdp_scorecard.hotel_num = 837 
AND UNIX_TIMESTAMP(bdp_scorecard.`created_date`) >= UNIX_TIMESTAMP("2011-11-26") 
AND UNIX_TIMESTAMP(bdp_scorecard.`created_date`) < UNIX_TIMESTAMP("2011-12-02 23:59:59") 

答えて

1

をテストすることはできませんが、それは誤り与える必要とされるであろうようにして、グループがいるようだ。..

SELECT 
    Sum(room_rev + room_rev_future) as weekly_room_rev, 
    Sum((`food_rev`) + (`beverage_rev`)) as weekly_catering_rev, 
    (SELECT min_sales_persons 
    FROM bdp_hotel_min WHERE 
    bdp_hotel_min.hotel_num = bdp_scorecard.hotel_num 
    AND UNIX_TIMESTAMP(bdp_hotel_min.`min_override_week`) 
    < UNIX_TIMESTAMP("2011-12-02 23:59:59") 
    ORDER BY bdp_hotel_min.`min_override_week` DESC LIMIT 1) as override_persons, 
    min_sales_persons 
FROM bdp_scorecard JOIN locations ON bdp_scorecard.hotel_num = locations.hotel_num 
WHERE bdp_scorecard.hotel_num =837 AND bdp_scorecard.hotel_num = 837 
AND UNIX_TIMESTAMP(bdp_scorecard.`created_date`) >= UNIX_TIMESTAMP("2011-11-26") 
AND UNIX_TIMESTAMP(bdp_scorecard.`created_date`) < UNIX_TIMESTAMP("2011-12-02 23:59:59") 
GROUP BY override_persons, min_sales_persons 
+0

はあなたに優しい先生ありがとうございました! – SirM

関連する問題