我是使用 Business Objects 以徒手 SQL 创建报表的最终用户。在过去的三个小时里,我一直在使用一些代码,并且不断收到错误消息“缺少右括号”。我已经看过这段代码很长时间了,现在我不确定错误是否突出显示我会看到它请帮助。代码如下:
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')