0

projections_report pここではとの 2 つのテーブルを使用していますaccess_rights a。エラーが発生する理由がわかりません:

サブクエリは複数の行を返します

(case when paramChannel='AllC' then p.gl_sal_chan in 
      (case when dc_lob=0 then (select distinct pr.gl_sal_chan from 
          projections_report pr) else (select distinct pr1.gl_sal_chan
                 from projections_report pr1 where pr1.gl_sal_chan 
                 in (select distinct a.gl_sal_chan from access_rights 
                 a where a.userid= paramUserId)) end) 
 else p.gl_sal_chan = paramChannel end)

すべてのキーワードと任意のキーワードを使用してみました。助けてください。

前もって感謝します。

4

2 に答える 2

0

サブクエリで USE LIMIT を使用して、distinct を使用しているため、1 つのレコードのみを返します。複数のレコードが返される場合があります。

于 2012-08-23T10:01:40.557 に答える
0

私は別の方法でそれをやろうとしましたが、うまくいきました。まず、2番目のcaseステートメントのelse条件のステートメントを次のように変更しました

(select distinct gl_sal_chan from access_rights where userid = paramUserid)

どちらも同じ結果を返すため(私の悪い)、次に条件全体を次のように変更しました

(case when (paramChannel = 'AllC' && dc_lob = 0) then '%' = '%' else 
    (case when (paramChannel='AllC' && dc_lob != 0) then 
    gl_sal_chan in (select distinct gl_sal_chan from access_rights where userid = paramUserid) 
else gl_sal_chan= paramChannel end)end)

とにかくありがとう @all :)

于 2012-08-23T09:58:21.660 に答える