我有一个包含以下列的表格
Date recd_amt paid_amnt counter
2013-01-01 899.00 120.00 1
2013-01-02 6988.00 255.00 1
2013-01-03 94.89 259.00 1
2013-01-01 589.50 255.00 2
2013-01-02 745.00 569.00 2
2013-01-03 298.00 985.00 2
2013-01-04 449.00 312.00 2
2013-01-04 271.00 255.00 1
我想以这种方式输出
Date Counter-1 Counter 2
Recd Amt Paid amnt Recd amnt Paid amnt
2013-01-01 899.00 120.00 589.50 255.00
我试过这个 sql 但不工作。请指出我错在哪里。
select date,
case when unit='1' then act_h3 end as u1acth3,
case when unit='1' then act_gb end as u1actgb
from systemactivity A
left join (select case when unit='2' then act_h3 end as u2acth3,
case when unit='2' then act_gb end as u2actgb
from systemactivity)b
on A.date = B.date