I have below 2 tables and I have to, write a query to display the sum of the total amount received through the credit card and cheque. Give the alias names as 'total_credit' and 'total_cheque' respectively.
table_payment
id (PK)
user_id
amount
transaction_type_id (FK)
table_transaction_type
id (PK)
type
Expected Output:
total_credit| total_cheque
Value a | Value B
I tried with below query but I getting values in different rows
select sum(case when tt.type = 'Credit Card' then pt.amount end) as
"total_credit", sum (case when tt.type = 'Cheque' then pt.amount end)
as "total_cheque" from payment pt join transaction_type tt on
pt.transaction_type_id = tt.id group by tt.type
Actual_Output:
total_credit| total_cheque
Value A |
| Value B
not sure how to get Value B in first row along with Value A, please advice.