user1082164 :
If I send the following query:
SELECT * FROM (
SELECT COUNT(*) as total, SUM(ABS(AMOUNT)) AS Total_Amount
FROM success_log
WHERE TRANSACTION = 'success' ) t1
CROSS JOIN (
SELECT COUNT(*) as success_total, SUM((AMOUNT)) AS success_Amount
FROM success_log WHERE
TRANSACTION = 'success' ) t2
CROSS JOIN (
SELECT COUNT(*) as Fail_total, SUM(ABS(AMOUNT)) AS Fail_Amount
FROM success_log
WHERE TRANSACTION = 'cancle') t3
result:
but I want result:
how to send query??
Jarri Abidi :
The following should work:
SELECT total,
Total_amount,
(total - Fail_total) AS success_total,
(Total_amount - Fail_amount) AS success_Amount,
Fail_total,
Fail_amount
FROM (
SELECT COUNT(*) as total,
SUM(ABS(AMOUNT)) AS Total_Amount
FROM success_log
WHERE TRANSACTION = 'success'
) t1
CROSS JOIN (
SELECT COUNT(*) as Fail_total,
SUM(ABS(AMOUNT)) AS Fail_Amount
FROM success_log
WHERE TRANSACTION = 'cancle'
) t3
Just to explain, your second cross join t2 wasn't returning the correct result so I used t1 and t3's original columns and added two other columns by subtracting their difference to show the success total and amount.