| Oracle Syntax error [message #319670] |
Mon, 12 May 2008 09:45  |
avrillavinge Messages: 23 Registered: July 2007 |
Junior Member |
|
|
correct query :
SELECT INSERT_COUNT.ACCOUNT_KEY, INSERT_COUNT.INSERT_CNT, UPDATE_COUNT.UPDATE_CNT
FROM
(SELECT Account_Key,COUNT(*) INSERT_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'I'
GROUP BY ACCOUNT_KEY,REC_STAT_CD) INSERT_COUNT
inner jOIN
(SELECT Account_Key,COUNT(*) UPDATE_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'U'
GROUP BY ACCOUNT_KEY,REC_STAT_CD) UPDATE_COUNT
ON INSERT_COUNT.ACCOUNT_KEY = UPDATE_COUNT.ACCOUNT_KEY
=============================the issue is below ==============
I want to add a delete flag count So I am making a table say X of the above query. Later making a left outer join of X with a query for Delete count.
But getting a error as syntax: 3706 Expected some thing between ‘)’ and the word X.
SELECT X.ACCOUNT_KEY, X.INSERT_CNT, X.UPDATE_CNT,DELETE_COUNT.DELETE_CNT
FROM
((SELECT Account_Key,COUNT(*) INSERT_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'I'
GROUP BY ACCOUNT_KEY,REC_STAT_CD) INSERT_COUNT
inner jOIN
(SELECT Account_Key,COUNT(*) UPDATE_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'U'
GROUP BY ACCOUNT_KEY,REC_STAT_CD) UPDATE_COUNT
ON INSERT_COUNT.ACCOUNT_KEY = UPDATE_COUNT.ACCOUNT_KEY)
X
left outer join (SELECT Account_Key,COUNT(*) DELETE_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'D'
GROUP BY ACCOUNT_KEY,REC_STAT_CD) DELETE_COUNT on
X.ACCOUNT_KEY=DELETE_COUNT.ACCOUNT_KEY
The error am getting
But getting a error as syntax: 3706 Expected some thing between ‘)’ and the word X
Regards,
Avril
|
|
|
| Re: Oracle Syntax error [message #319674 is a reply to message #319670 ] |
Mon, 12 May 2008 10:00   |
avrillavinge Messages: 23 Registered: July 2007 |
Junior Member |
|
|
|
am not able to figure out wat is the syntax issue
|
|
|
| Re: Oracle Syntax error [message #319675 is a reply to message #319674 ] |
Mon, 12 May 2008 10:07   |
anacedent Messages: 6216 Registered: July 2005 Location: surf meets turf in SoCal |
Senior Member |
|
|
| avrillavinge wrote on Mon, 12 May 2008 08:00 | am not able to figure out wat is the syntax issue
|
neither can I.
http://www.orafaq.com/forum/t/88153/0/
Please read & follow posting guidelines as stated in URL above
|
|
|
| Re: Oracle Syntax error [message #319676 is a reply to message #319674 ] |
Mon, 12 May 2008 10:07   |
Michel Cadot Messages: 17696 Registered: March 2007 Location: Nanterre, France, http://... |
Senior Member |
|
|
Do do I, I am unbale to read unformated post.
please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter).
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).
Regards
Michel
|
|
|
| Re: Oracle Syntax error [message #319685 is a reply to message #319670 ] |
Mon, 12 May 2008 10:58   |
S.Rajaram Messages: 670 Registered: October 2006 Location: United Kingdom |
Senior Member |
|
|
Don't you think this looks lot more readable and easier to understand. Formatting always helps.
SELECT X.ACCOUNT_KEY, X.INSERT_CNT, X.UPDATE_CNT,DELETE_COUNT.DELETE_CNT
FROM
(
select insert_count.account_key from -- I have added this line
(
SELECT Account_Key,COUNT(*) INSERT_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'I'
GROUP BY ACCOUNT_KEY,REC_STAT_CD
) INSERT_COUNT
inner jOIN
(
SELECT Account_Key,COUNT(*) UPDATE_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'U'
GROUP BY ACCOUNT_KEY,REC_STAT_CD
) UPDATE_COUNT
ON INSERT_COUNT.ACCOUNT_KEY = UPDATE_COUNT.ACCOUNT_KEY
) X
left outer join
(
SELECT Account_Key,COUNT(*) DELETE_CNT
FROM HCDB_AIFA3100_HIST_V
WHERE REC_STAT_CD = 'D'
GROUP BY ACCOUNT_KEY,REC_STAT_CD
) DELETE_COUNT
on X.ACCOUNT_KEY = DELETE_COUNT.ACCOUNT_KEY
Regards
Raj
P.S : I have not tested the code.
|
|
|
|
| Re: Oracle Syntax error [message #319693 is a reply to message #319670 ] |
Mon, 12 May 2008 12:30  |
joy_division Messages: 2120 Registered: February 2005 Location: NY |
Senior Member |
|
|
| avrillavinge wrote on Mon, 12 May 2008 10:45 |
The error am getting
But getting a error as syntax: 3706 Expected some thing between ‘)’ and the word X
|
linuxy SCOTT>!oerr ora 3706
37060, 0000, "(XSMCSESS08) %v is not a valid custom member in dimension %j."
// *Cause: No custom member or invalid custom member
// *Action: Create the custom member or use the correct custom member
|
|
|