2
這是我當前的SQL查詢:上述查詢的如何更改SQL選擇查詢作爲SQL Server CE中的新表?
SELECT
SUM(CASE WHEN (DATEDIFF(day, tbl_debit.purchasedate, GETDATE()) >= 45)
THEN tbl_invoices.pendingamount ELSE 0 END) AS morethan45,
SUM(CASE WHEN (DATEDIFF(day, tbl_debit.purchasedate, GETDATE()) < 45)
THEN tbl_invoices.pendingamount ELSE 0 END) AS lessthan45
FROM
tbl_debit
INNER JOIN
tbl_invoices ON tbl_debit.invoice = tbl_invoices.invoice
WHERE
(tbl_invoices.state = - 1)
輸出如下所示:
morethan45 | lessthan45
750 | 710
我想創建一個新的表像之下。是否有可能在group by
創造新的東西像下面
Column 1 | Column 2
morethan45 | 750
lessthan45 | 710