0
我有以下Mysql過程。MySql在單行中獲取多行
select
case temp.lineItemTypeID when 1 then temp.tt else 0 end case as planTotalAmount,
case temp.lineItemTypeID when 2 then temp.tt else 0 end case as discountTotalAmount
from (
SELECT
lineItemTypeID,
sum(lineitemAmount) as tt from tbl_invoicelineitem
where date(lineItemcreatedDate) IS NOT NULL
group by lineItemTypeID
) temp;
我想要結果是單個返回子查詢。 例如:
planTotalAmount | discountTotalAmount
10 | 2 `
但我正在逐漸
planTotalAmount | discountTotalAmount
10 | 0
0 | 2 `
如何解決呢?