0
我有一個表中放置這樣選擇一個表兩次在MySQL獲得行數據爲列數據
Date Counter-1 Counter 2
Recd Amt Paid amnt Recd amnt Paid amnt
2013-01-01 899.00 120.00 589.50 255.00
以下幾列
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
我想離開這個我試過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
是的,哈姆扎庫巴先是:) –
哈,你是非常接近的第二個。 :) –