-1

私はビジネス オブジェクトを使用してフリーハンド SQL でレポートを作成するエンド ユーザーです。過去 3 時間、いくつかのコードで作業しており、"Missing Right Parenthese" というエラー メッセージが表示され続けています。このコードをずっと見てきたので、エラーが強調表示されているかどうかわかりません。助けてください。コードは以下のとおりです。

SELECT   
decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project,
      nvl(Year1.TotAmt,0) "2007", nvl(Year2.TotAmt,0) "2008", nvl(Year3.TotAmt,0) "2009", 
      nvl(Year4.TotAmt,0) "2010", nvl(Year5.TotAmt,0) "2011",nvl(Year6.TotAmt,0) "2012",
nvl(Year7.TotAmt,0) "2013"
from payment p,
--- Year 1
   (select sum(p.payamount) TotAmt, (usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project, 
           max(to_char(paydate,'yyyy')) Year
   from   payment p
   where  trunc(p.paydate) between @prompt('1.Enter Start Date For Period in FIRST Year','D',,,) and 
                                    @prompt('2.Enter End Date For Period in FIRST Year','D',,,) and 
          p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
          p.usercode1 in ('005','016','021','031','033','041','044')
   group by 
         decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')) Year1,
--- Year 2
(select sum(p.payamount) TotAmt, (usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project, 
           max(to_char(paydate,'yyyy')) Year
   from   payment p
   where  trunc(p.paydate-366) between @prompt('1.Enter Start Date For Period in FIRST Year','D',,,) and 
                                        @prompt('2.Enter End Date For Period in FIRST Year','D',,,) and 
          p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
          p.usercode1 in ('005','016','021','031','033','041','044')
   group by 
         decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')) Year2,
--- Year 3
   (select sum(p.payamount) TotAmt, (usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project, 
           max(to_char(paydate,'yyyy')) Year
   from   payment p
   where  trunc(p.paydate-731) between @prompt('1.Enter Start Date For Period in FIRST Year','D',,,) and 
                                        @prompt('2.Enter End Date For Period in FIRST Year','D',,,) and 
          p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
          p.usercode1 in ('005','016','021','031','033','041','044')
   group by 
         decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')) Year3,
--- Year 4
    (select sum(p.payamount) TotAmt, (usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project, 
           max(to_char(paydate,'yyyy')) Year
   from   payment p
   where  trunc(p.paydate-1096) between @prompt('1.Enter Start Date For Period in FIRST Year','D',,,) and 
                                        @prompt('2.Enter End Date For Period in FIRST Year','D',,,) and 
          p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
           p.usercode1 in ('005','016','021','031','033','041','044')
  group by 
         decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')) Year4,
--- Year 5
  (select sum(p.payamount) TotAmt, (usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project, 
           max(to_char(paydate,'yyyy')) Year
   from   payment p
   where  trunc(p.paydate-1461) between @prompt('1.Enter Start Date For Period in FIRST Year','D',,,) and 
                                        @prompt('2.Enter End Date For Period in FIRST Year','D',,,) and 
          p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
           p.usercode1 in ('005','016','021','031','033','041','044')
  group by 
         decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')) Year5,

--- Year 6
     (select sum(p.payamount) TotAmt, (usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project, 
           max(to_char(paydate,'yyyy')) Year
   from   payment p
   where  trunc(p.paydate-1826) between @prompt('1.Enter Start Date For Period in FIRST Year','D',,,) and 
                                    @prompt('2.Enter End Date For Period in FIRST Year','D',,,) and 
          p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
           p.usercode1 in ('005','016','021','031','033','041','044')
   group by 
         decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')) Year6,

--- Year 7
   (select sum(p.payamount) TotAmt, (usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') Project, 
           max(to_char(paydate,'yyyy')) Year
   from   payment p
   where  trunc(p.paydate-2192) between @prompt('1.Enter Start Date For Period in FIRST Year','D',,,) and 
                                    @prompt('2.Enter End Date For Period in FIRST Year','D',,,) and 
          p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
          p.usercode1 in ('005','016','021','031','033','041','044')
    group by 
         decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')) Year7



where  p.paydate between to_date ('10/01/2007','mm/dd/yyyy') and 
                          to_date ('12/31/2013','mm/dd/yyyy') and 
       p.CLASSCODE  NOT IN  ('NONGIF', 'PCRED') and
        p.usercode1 in ('005','016','021','031','033','041','044') and
       decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') = Year1.Project(+) and
       decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') = Year2.Project(+) and
       decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') = Year3.Project(+) and
      decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') = Year4.Project(+) and
       decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')= Year5.Project(+) and
     decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') = Year6.Project(+)  and


     decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts') = Year7.Project(+) 



group by 
decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts'),
       Year1.TotAmt, Year2.TotAmt, Year3.TotAmt, Year4.TotAmt, Year5.TotAmt, Year6.TotAmt,Year7.TotAmt
order by 
      decode(usercode1, '005','Major Gifts','016','Major Gifts','021','Major Gifts','031','Major Gifts',
                  '033','Major Gifts','041','Major Gifts',
                  '044','Major Gifts')
4

1 に答える 1

2

Year サブクエリには、次のようなコードがあります(usercode1, ...) Projectdecodeそれぞれの前に が必要です。

余談ですが、これらの問題をより簡単に特定できるように、ブラケット マッチングを行うテキスト エディター (gvim など) を入手することをお勧めします。

于 2013-05-24T00:42:21.960 に答える