(SELECT
subaccount.Fin_ID,
SUM(subaccount.May61)
FROM
subaccount
group by Fin_ID)
union ALL
(SELECT
account.Fin_ID,
sum(detail.Cost)
FROM
detail
INNER JOIN account ON detail.Acc_ID = account.Acc_ID
where AMonth = '5'
group by Fin_ID
having Fin_ID > 'P13'
)
ขอบคุณมากค่ะ
Date :
2018-07-17 15:34:37
By :
pum374
No. 7
Guest
Code (SQL)
select isnull(a.Fin_ID,b.Fin_ID) as Fin_ID,a.sum1,b.sum2
from
(SELECT
subaccount.Fin_ID,
SUM(subaccount.May61) as sum1
FROM
subaccount
group by Fin_ID) a
full outer join
(SELECT
account.Fin_ID,
sum(detail.Cost) as sum2
FROM
detail
INNER JOIN account ON detail.Acc_ID = account.Acc_ID
where AMonth = '5'
group by Fin_ID
having Fin_ID > 'P13'
) b on b.Fin_ID = a.Fin_ID
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b.Fin_ID) as Fin_ID,a.sum1,b.sum2
from
(SEL...
ขึ้น error แบบนี้ค่ะ รบกวนด้วยนะคะ
Date :
2018-07-17 16:09:16
By :
pum374
No. 9
Guest
Code (SQL)
select (case when a.Fin_ID != null then a.Fin_ID else b.Fin_ID end) as Fin_ID,a.sum1,b.sum2
from
(SELECT
subaccount.Fin_ID,
SUM(subaccount.May61) as sum1
FROM
subaccount
group by Fin_ID) a
full outer join
(SELECT
account.Fin_ID,
sum(detail.Cost) as sum2
FROM
detail
INNER JOIN account ON detail.Acc_ID = account.Acc_ID
where AMonth = '5'
group by Fin_ID
having Fin_ID > 'P13'
) b on b.Fin_ID = a.Fin_ID