2012-03-26 7 views
0

私の質問は徐々に難しくなってきていますので、明らかに私をよく教えています! カードの確認に関する詳細を印刷するレポートがあります。 この場合、「ターンアラウンドリクエスト」のすべてのインスタンスで空白のCTYlongに表示されていないフィールドの確認リクエストを「ターンアラウンドリクエスト」に変更した場合を除き、すべてのフィールドは正常に入力されます。これはssrsのです 私はあなたにそれを残すよ!レポートのセクションにフィールドが表示されない

IF @MsgType = 200 
BEGIN 
SELECT DISTINCT MsgType = 'confirm Request' , resp.dtTimeRPO as  HostTime , 
                  resp.sSTANExternalI as STAN , 
resp.sterminal_TerminalID as TerminalID ,  resp.ssell_CardAcceptorIDCode as  

sellID , resp.ssell_CardAcceptorNameLoc as sellName , 

STUFF(resp.span_Pan,7,(LEN(resp.span_Pan)-10), REPLICATE('X',(LEN(resp.span_Pan)-10))) 
as PAN , CAST(MONTH(resp.dtpan_ExpiryDate) as varchar(2)) + '/' + 
CAST(YEAR(resp.dtpan_ExpiryDate) as char(4)) as ExpDate , CAST(resp.namounts_cAmount 
as float)/100 as Amount , resp.namounts_CurrencyCodetx as CurrencyCode , 
resp.nActionCode as RC , rc.rcInfo as RCDesc , resp.sconfirmCode as confirmCode , 
    ssell_CountryShort2 AS sell_Country , ctylong , 

    (SELECT DATEPART(ss, resp.dtTimeRPO - req.dtTimeRQI) FROM dbo.txHistory as  
    req (NOLOCK) 

WHERE req.sSTANExternalI = resp.sSTANExternalI 
AND 
req.namounts_cAmount = resp.namounts_cAmount 
AND req.dtLocalDateTime = resp.dtLocalDateTime 
AND RTRIM(req.sPHProfile) = @Head 
AND (req.sconfirmCode = '' 
AND req.nActionCode = 0) 
AND req.dtTimeRQI BETWEEN DATEADD(mi, -1, @StartDate) 
AND @EndDate) as Duration 
FROM dbo.txHistory as resp (NOLOCK) 
INNER JOIN dbo.replyCode as rc (NOLOCK) 
ON resp.nActionCode = rc.rcCode 
inner join country (nolock) 
on nsell_countrycode = ctycode 
WHERE resp.dtTimeRPO 
BETWEEN @StartDate AND @EndDate 
AND 
resp.eMTI = @MsgType 
AND 
RTRIM(resp.sPHProfile) = @Head 
AND NOT (resp.sconfirmCode = '' AND resp.nActionCode = 0) 
ORDER BY resp.dtTimeRPO 
END 
ELSE 
BEGIN 
SELECT DISTINCT MsgType = 'turnaround Request' , resp.dtTimeRPO as HostTime , 
resp.sSTANExternalI as STAN , resp.sterminal_TerminalID as TerminalID , 
    resp.ssell_CardAcceptorIDCode as sellID , resp.ssell_CardAcceptorNameLoc 
    as sellName , STUFF(resp.span_Pan,7,(LEN(resp.span_Pan)-10), REPLICATE('X', 
    (LEN(resp.span_Pan)-10))) as PAN , CAST(MONTH(resp.dtpan_ExpiryDate) as varchar(2)) + 
'/' + CAST(YEAR(resp.dtpan_ExpiryDate) as char(4)) as ExpDate , 
CAST(resp.namounts_cAmount as float)/100 as Amount , 
    resp.namounts_CurrencyCodetx as CurrencyCode , resp.nActionCode as RC , 
    rc.rcInfo as RCDesc , resp.sconfirmCode as confirmCode , 

    (SELECT DATEPART(ss, resp.dtTimeRPO - req.dtTimeRQI) 
FROM dbo.txHistory as req (NOLOCK) 
WHERE req.sSTANExternalI = resp.sSTANExternalI AND req.namounts_cAmount =  
    resp.namounts_cAmount AND req.dtLocalDateTime = resp.dtLocalDateTime 
AND 
    RTRIM(req.sPHProfile) = @Head 
    AND 
    (req.eMTI = 420 AND req.nActionCode = 400) 
AND 
req.dtTimeRQI BETWEEN DATEADD(mi, -1, @StartDate) AND @EndDate) 
as Duration 
FROM dbo.txHistory as resp (NOLOCK) 
INNER JOIN dbo.replyCode as rc (NOLOCK) ON resp.nActionCode = rc.rcCode WHERE  
resp.dtTimeRPO 
BETWEEN 
@StartDate 
AND @EndDate AND resp.eMTI = @MsgType 
AND RTRIM(resp.sPHProfile) = @Head 
ORDER BY resp.dtTimeRPO END 

答えて

3

逆戻りリクエストの場合、ctylongフィールドは含まれていません。基本的には、2つのクエリに列が並んでいません。あなたは本当にあなたのクエリをよりよくフォーマットしなければなりません。それは読書の悪夢でした。

編集:これは私が私のクエリをフォーマットしたい方法です

SELECT 
    column1, 
    column2, 
    column3 
FROM 
    table_1 INNER JOIN 
    table_2 ON table_1.id = table_2.id INNER JOIN 
    (
     SELECT 
     column_4 
     FROM 
     table_3 
    ) t3 ON table_2.id = t3.id 
WHERE 
    table_1.id = 1000 AND 
    table_2.id = 2000