I have Two tables OPPatient AND Pharmacy
select SUM(Amtpaid)
from OPPatient
where startdate >= '2024-11-01' AND enddate < '2024-12-01'
select Sum(Amtpaid)
from Pharmacy
where startdate >= '2024-11-01' AND enddate < '2024-12-01'
Need output like
AmtPaid | AmtPaid |
---|---|
10000 | 40000 |
Tried above query which is returning AmtPaid with 2 record like
AmtPaid |
---|
10000 |
40000 |
but i need as
AmtPaid | AmtPaid |
---|---|
100000 | 40000 |
3条答案
按热度按时间fwzugrvs1#
Just
select
both values:laawzig22#
You can use cte to solve the problem
You can create insert Base data with the following statements:
kmbjn2e33#
This is an other way to pivot your result using the aggregate function
MAX()
withCASE
clause :Result :
Demo here