将TRANSFORM访问查询转换为SQL Server

时间:2014-06-11 17:35:31

标签: sql sql-server ms-access pivot transform

我希望将以下TRANSFORM语句从Access转换为SQL Server。

TRANSFORM case when sum(a.RE_Amt) = NUll then 0
    when sum(a.RE_Amt) is NUll then 0
    else sum(a.RE_Amt) end as AJE_AmountAS Restated_Amount
 SELECT A.Deal, A.Entity, A.StatementDate, A.From_Date, A.To_Date, 
 A.PostingDate, A.CUSIP, A.AME
 FROM (SELECT tbl_CUSIP_Compare_ALL.deal, tbl_CUSIP_Compare_ALL.Entity, 
 tbl_CUSIP_Compare_ALL.statementdate, tbl_CUSIP_Compare_ALL.From_Date, 
 tbl_CUSIP_Compare_ALL.To_Date, tbl_CUSIP_Compare_ALL.PostingDate, 
 tbl_CUSIP_Compare_ALL.CUSIP, tbl_CUSIP_Compare_ALL.Orig_Amt, 
 tbl_CUSIP_Compare_ALL.Re_Amt, tbl_CUSIP_Compare_ALL.AJE_Amt, 
 tbl_CUSIP_Compare_ALL.Type, tbl_CUSIP_Compare_ALL.AME
 FROM tbl_CUSIP_Compare_ALL
 where tbl_CUSIP_Compare_ALL.deal like '*2010-R3*'
 and tbl_CUSIP_Compare_ALL.PostingDate = #5/31/2015 #)  AS A
 GROUP BY A.Deal, A.AME, A.Entity, A.StatementDate, A.From_Date, 
 A.To_Date, A.PostingDate, A.CUSIP, A.AME
 PIVOT A.Type;

我无法找到办法。任何帮助都会得到帮助!

0 个答案:

没有答案