请帮找错 晕大了,该怎么处理
请帮找错 晕大了
$sql="SELECT * FROM (
SELECT newday,ulname1 SUM(newcharge) AS new_charge FROM (
SELECT date_format(check_end_date,'".$x."') AS newday ,SUM(a.user_charge+0) AS newcharge,user_login_name as ulname1 FROM table1 a GROUP BY date_format(check_end_date,'".$x."')
UNION ALL
SELECT date_format(user_login_time,'".$x."') ,SUM(a.user_charge+0) FROM table2 a GROUP BY date_format(user_login_time,'".$x."')) a GROUP BY newday
) a1
LEFT JOIN
(SELECT user_zone_group as uzg,user_login_name as ulname2,user_group_id as ugid FROM tab1 ) a2
ON a1.ulname=a2.ulname2
LEFT JOIN
(SELECT user_group_id as ugid2 FROM tab12 ) a3
ON a2.ugid=a3.ugid2
UNION ALL
SELECT DISTINCT 'total',
(SELECT SUM(newcharge) AS new_charge FROM (
SELECT date_format(check_end_date,'".$x."') AS newday ,SUM(a.user_charge+0) AS newcharge FROM table1 a GROUP BY date_format(check_end_date,'".$x."')
UNION ALL
SELECT date_format(user_login_time,'".$x."'),SUM(a.user_charge+0) FROM table2 a GROUP BY date_format(user_login_time,'".$x."'))
a)s2 FROM s2 ORDER BY newday DESC";
------解决方案--------------------
什么错误? 错误提示是什么?
$sql="SELECT * FROM (
SELECT newday,ulname1 SUM(newcharge) AS new_charge FROM (
SELECT date_format(check_end_date,'".$x."') AS newday ,SUM(a.user_charge+0) AS newcharge,user_login_name as ulname1 FROM table1 a GROUP BY date_format(check_end_date,'".$x."')
UNION ALL
SELECT date_format(user_login_time,'".$x."') ,SUM(a.user_charge+0) FROM table2 a GROUP BY date_format(user_login_time,'".$x."')) a GROUP BY newday
) a1
LEFT JOIN
(SELECT user_zone_group as uzg,user_login_name as ulname2,user_group_id as ugid FROM tab1 ) a2
ON a1.ulname=a2.ulname2
LEFT JOIN
(SELECT user_group_id as ugid2 FROM tab12 ) a3
ON a2.ugid=a3.ugid2
UNION ALL
SELECT DISTINCT 'total',
(SELECT SUM(newcharge) AS new_charge FROM (
SELECT date_format(check_end_date,'".$x."') AS newday ,SUM(a.user_charge+0) AS newcharge FROM table1 a GROUP BY date_format(check_end_date,'".$x."')
UNION ALL
SELECT date_format(user_login_time,'".$x."'),SUM(a.user_charge+0) FROM table2 a GROUP BY date_format(user_login_time,'".$x."'))
a)s2 FROM s2 ORDER BY newday DESC";
------解决方案--------------------
什么错误? 错误提示是什么?