Maximum number of DECODE in a select statement
Is there a limit on the number of Decodes a statement select SQL can handle?I ran the following statement and it's what gives an error after the 3rd DECODE.
Any idea of a solution is much appreciated.
Thank you.
SQL > SELECT
2 NAME, DIRECTION. DIRECTORATE_ID, AFC,
V_ADJUSTMENT_ACTUAL_RESULT 3. FUND, V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE,
4 ADJUSTMENT_PCT, V_ADJUSTMENT_ACTUAL_RESULT.FY,
5 DECODE (V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE, "FD", SUM (PP21 PP22 + PP23 + PP24 + PP25 + PP26 + DP1 + PP
2 PP3 + + PP4 PP5 + + PP6 PP7 + + PP8 PP9 + PP10 + PP11 + PP12 + PP13 + PP14 + PP15 + PP16 AND PP17 + PP18 + PP19 + PP20)) AS FD,
6 DECODE (V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE, 'FR', SUM (PP21 PP22 + PP23 + PP24 + PP25 + PP26 + DP1 + PP
2 PP3 + + PP4 PP5 + + PP6 PP7 + + PP8 PP9 + PP10 + PP11 + PP12 + PP13 + PP14 + PP15 + PP16 AND PP17 + PP18 + PP19 + PP20)) AS EN.
7 DECODE (V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE, "OD", SUM (PP21 PP22 + PP23 + PP24 + PP25 + PP26 + DP1 + PP
2 PP3 + + PP4 PP5 + + PP6 PP7 + + PP8 PP9 + PP10 + PP11 + PP12 + PP13 + PP14 + PP15 + PP16 AND PP17 + PP18 + PP19 + PP20)) THAN OD.
8 DECODE (V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE, 'OR', SUM (PP21 PP22 + PP23 + PP24 + PP25 + PP26 + DP1 + PP
2 PP3 + + PP4 PP5 + + PP6 PP7 + + PP8 PP9 + PP10 + PP11 + PP12 + PP13 + PP14 + PP15 + PP16 AND PP17 + PP18 + PP19 + PP20)) AS OR.
9 DECODE (V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE, "FF", SUM (PP21 PP22 + PP23 + PP24 + PP25 + PP26 + DP1 + PP
2 PP3 + + PP4 PP5 + + PP6 PP7 + + PP8 PP9 + PP10 + PP11 + PP12 + PP13 + PP14 + PP15 + PP16 AND PP17 + PP18 + PP19 + PP20)) LIKE FF
10 FROM
11. THE STAFFING. V_ADJUSTMENT_ACTUAL_RESULT,
12. THE STAFFING. ADJUSTMENT,
13. THE STAFFING. DIRECTION OF
14. WHERE
15. THE STAFFING. V_ADJUSTMENT_ACTUAL_RESULT. DIRECTORATE_ID = STAFFING. DIRECTORATE GENERAL. DIRECTORATE_ID
16 AND THE WORKFORCE. SETTING. DIRECTORATE_ID = STAFFING. V_ADJUSTMENT_ACTUAL_RESULT. DIRECTORATE_ID
17 GROUP OF
DIRECTORATE.NAME 18,
19 DIRECTION. DIRECTORATE_ID,
20 V_ADJUSTMENT_ACTUAL_RESULT. AFC,
21 V_ADJUSTMENT_ACTUAL_RESULT. FUNDS,
22 V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE,
23 SETTING. ADJUSTMENT_PCT,
24 V_ADJUSTMENT_ACTUAL_RESULT.FY
25 ORDER BY
DIRECTORATE.NAME 26,
27 DIRECTION. DIRECTORATE_ID,
28 V_ADJUSTMENT_ACTUAL_RESULT. AFC,
29 V_ADJUSTMENT_ACTUAL_RESULT. FUNDS,
30 V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE,
31 SETTING. ADJUSTMENT_PCT,
32 V_ADJUSTMENT_ACTUAL_RESULT.FY;
DECODE (V_ADJUSTMENT_ACTUAL_RESULT. FUND_TYPE, 'OR', SUM (PP21 PP22 + PP23 + PP24 + PP25 + PP26 + DP1 + PP2 + PP3
ERROR on line 8:
ORA-00923: THE KEYWORD not found where expected
Published by: user551757 on January 28, 2009 13:17
The last line of your code is oncorrect.
Or is a reserved word in Oracle.
Try this code.
Kind regards.
Salim.
SELECT NAME, directorate.directorate_id, afc,
v_adjustment_actual_result.fund,
v_adjustment_actual_result.fund_type, adjustment_pct,
v_adjustment_actual_result.fy,
DECODE (v_adjustment_actual_result.fund_type,
'FD', SUM ( pp21
+ pp22
+ pp23
+ pp24
+ pp25
+ pp26
+ pp1
+ pp2
+ pp3
+ pp4
+ pp5
+ pp6
+ pp7
+ pp8
+ pp9
+ pp10
+ pp11
+ pp12
+ pp13
+ pp14
+ pp15
+ pp16
+ pp17
+ pp18
+ pp19
+ pp20
)
) AS fd,
DECODE (v_adjustment_actual_result.fund_type,
'FR', SUM ( pp21
+ pp22
+ pp23
+ pp24
+ pp25
+ pp26
+ pp1
+ pp2
+ pp3
+ pp4
+ pp5
+ pp6
+ pp7
+ pp8
+ pp9
+ pp10
+ pp11
+ pp12
+ pp13
+ pp14
+ pp15
+ pp16
+ pp17
+ pp18
+ pp19
+ pp20
)
) AS fr,
DECODE (v_adjustment_actual_result.fund_type,
'OD', SUM ( pp21
+ pp22
+ pp23
+ pp24
+ pp25
+ pp26
+ pp1
+ pp2
+ pp3
+ pp4
+ pp5
+ pp6
+ pp7
+ pp8
+ pp9
+ pp10
+ pp11
+ pp12
+ pp13
+ pp14
+ pp15
+ pp16
+ pp17
+ pp18
+ pp19
+ pp20
)
) AS od,
DECODE (v_adjustment_actual_result.fund_type,
'OR', SUM ( pp21
+ pp22
+ pp23
+ pp24
+ pp25
+ pp26
+ pp1
+ pp2
+ pp3
+ pp4
+ pp5
+ pp6
+ pp7
+ pp8
+ pp9
+ pp10
+ pp11
+ pp12
+ pp13
+ pp14
+ pp15
+ pp16
+ pp17
+ pp18
+ pp19
+ pp20
)
) AS orr,
DECODE (v_adjustment_actual_result.fund_type,
'FF', SUM ( pp21
+ pp22
+ pp23
+ pp24
+ pp25
+ pp26
+ pp1
+ pp2
+ pp3
+ pp4
+ pp5
+ pp6
+ pp7
+ pp8
+ pp9
+ pp10
+ pp11
+ pp12
+ pp13
+ pp14
+ pp15
+ pp16
+ pp17
+ pp18
+ pp19
+ pp20
)
) AS ff
FROM staffing.v_adjustment_actual_result,
staffing.adjustment,
staffing.directorate
WHERE staffing.v_adjustment_actual_result.directorate_id =
staffing.directorate.directorate_id
AND staffing.adjustment.directorate_id =
staffing.v_adjustment_actual_result.directorate_id
GROUP BY directorate.NAME,
directorate.directorate_id,
v_adjustment_actual_result.afc,
v_adjustment_actual_result.fund,
v_adjustment_actual_result.fund_type,
adjustment.adjustment_pct,
v_adjustment_actual_result.fy
ORDER BY directorate.NAME,
directorate.directorate_id,
v_adjustment_actual_result.afc,
v_adjustment_actual_result.fund,
v_adjustment_actual_result.fund_type,
adjustment.adjustment_pct,
v_adjustment_actual_result.fy;
Tags: Database
Similar Questions
-
Maximum number of list to multiple selection on a page
Greetings,
I use the Application Express 4.2.1.00.08. I have a problem in one of my pages. I have several items (123 from today ' hui), and two of them are lists of multiple selections. They are all the same... created is based on a named LOV, together forever, used Source Source Type defined on the database column... and they all work fine, except the last. Don't just save to the database.
I tried:
-Delete and recreate from scratch - does not save
-Deletion and recreation of one copy of another list selection multiple work - does not save
-Change the view state for one of my multiple selections of work lists to never (to have a less rendered multiselect list) - does not save
-Keep everything the same but by changing the type of element (text field) - saves
-Keeping all the same, but change to a normal selection list (no) - saves
So, I came to the point of wondering... is there a limit on how many multiple-selection list can be on a page?
If so, does anyone know a kind of workaround?
If this isn't the case, anyone has an idea why I'm having this problem?
Thank you for your comments,
MathieuI found something. If I move the item to another region, it works again, but not in all regions. I tried to create a new region and delete my article in there, but it doesn't seem to work. I'll keep looking.
Thank you
Mathieu -
I have a problem
I have INV_REG table where assets are stored
and here the genereates inventory number (corresponding inv_no) like this:
ABC-025145-2009
DONORS-SRNO-YEAR
now, I want to get maximum number of series that will come from donors. I draw the following question, but I can not guide kindly maximum number me...
Select corresponding inv_no, substr (inv_no, instr(inv_no,'-') + 1, instr(inv_no,'-')-1) sr_no
of inv_reg
where don_code =: don_code;
result:
---------
SR_NO INV_NO CORRESPONDENT
AC-AD2-0272-2003 HD
ABC-9428-2006 9428
ABC-9426-2006 9426I use oracle 9i database...
Should always be the first line in a post ;)
Yet once, assuming no revenue for DONORS:
SQL> with t as ( select 'AC-HDIT-0272-2003' inv_no from dual union all select 'ABC-9428-2006' from dual union all select 'ABC-9426-2006' from dual ) -- -- select inv_no, trim ('-' from rtrim (replace (inv_no, rtrim (inv_no, '0123456789-')), '0123456789')) ser_no from t / INV_NO SER_NO ------------------------- ------------------------- AC-HDIT-0272-2003 0272 ABC-9428-2006 9428 ABC-9426-2006 9426 3 rows selected.
-
to find the number of records retrieved in the select statement in the cursor
Hi all
with the cursor, I'm selecting select statement together and writing in the .txt file.
his worksheet, but it should not open the file, if the cursor returns nothing.
How to find the number of records returned by the select statement in the cursor.
pls help me.
Thank you...Don't understand what you're trying to say, but maybe it's...
DECLARE vCounter NUMBER; -- Other variables... BEGIN vCounter:=0; FOR .. IN cursor LOOP IF vCounter=0 THEN -- Here open file... -- Here write one time data... END IF; -- Here write cursor data... vCounter:=1; END LOOP; END;
-Clément
-
ORA-00020: maximum number of processes exceeded
All respected DBAs,
Today I faced an issue. I found below statement alertlog file and when I tried to connect to the base of this error came on the command line.
"ORA-00020: maximum number of processes exceeded 150.
Then I restarted my Oracle Service, connected to the database and questioned
select * from v$ resource_limit and found this result.
Process
CURRENT_UTILIZATION = 52
MAX_UTILIZATION = 61
INITIAL_ALLOCATION = 150
LIMIT_VALUE = 150
Sessions
CURRENT_UTILIZATION = 53
MAX_UTILIZATION = 60
INITIAL_ALLOCATION = 248
LIMIT_VALUE = 248
If my process is exceeded then why MAX_UTILIZATION = 61 only? Please, help me to understand this.
This view is dynamic (it will reset on reboot) and restart you the database.
So you can only say that after the restart of the database the number of processes is already 61.
-------------
Sybrand Bakker
Senior Oracle DBA
-
ORA-00018. Exceed the maximum number of sessions
Hi all
I have a windows Server 2003, oracle 10g release 2.
connection of 300 users competitor.
My SESSIONS parameter = 800
My PROCESS parameter = 723.
After 2 or 3 days, I got the following message when I try to connect.
ORA-00018. Maximum number of sessions to exceed.
even I have restart my server, I got this number sometimes.
What is the problem? I'm really in a very bad situation, users can not connected.
Thank youPlease post output commands below:
Select the value of the parameter $ v where name = "sessions";
Select count (*) in the session of v$.
Select * from v$ resource_limit;If you see the 3rd command output as equal values in all the columns then its correct and Oracle returned ORA-00018.
Then, V$ SESSION is fake! It does not report all sessions really in use. If you look in V$ SESSION see text (with the help of V$ FIXED_VIEW_DEFINITION), you will see that V$ SESSION reports of the sessions USER and only BACKGROUND.
But there is a 3rd type of session - a RECURSIVE session, which is used for recursive calls data dictionary as explained above. V$ SESSION does not display these.
So what is the moral of this story?
Oracle uses recursive sessions for recursive data dictionary operations
These sessions are also taken from the array of objects in session state controlled by the session setting
V$ SESSION shows no recursive sessions, but V$ RESOURCE_LIMIT told it the truth about the use of the session state object table
If you hit the error ORA-00018, and then expand your table of parameters of sessions or configure your application to use fewer connections or sessionsNote that Oracle 11.2 changed the automatic calculation of parameters of sessions and large number of session state objects is attributed to a number of default process.
Source: http://tech.e2sn.com/oracle/oracle-internals-and-architecture/recursive-sessions-and-ora-00018-maximum-number-of-sessions-exceeded
Concerning
Girish Sharma -
How to add an imaginary line in the result of the value of a SELECT statement.
Hello all-
I have requirment to add an imaginary line in the result set of a SELECT statement.
For example lets say it is a pay table having the following columns:
Number of Payment_id
status varchar2 (10)
number amount
date of payment_date
so here's the data: -.
Payment_id status amount payment_date
applied 1 100 12/07/2008
2 Reversed 200 01 / 06/2009
Applied 3 300 01 / 07/2009
Here is my SQL
Select * form payment where payment_date > = 01/01/2009
The output will be
2 Reversed 200 01 / 06/2009
Applied 3 300 01 / 07/2009
My desired output is less than
2 Reversed 200 01 / 06/2009
Applied 3 300 01 / 07/2009
reversed-200 2, 01 / 06/2009-(Dummy Row)
Third line here is the imaginary line that I add when the status is "reversed".
I would be very grateful for any help on this...
Thank you
GerardCartesion join against a shadow table is a useful method to create a fictitious line:
with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual), --- end of mimicking your table dummy as (select 'Reversed' col1, 1 rn from dual union all select 'Reversed' col1, 2 rn from dual) select mt.cust_id, mt.payment_id, mt.status, decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount, mt.payment_date from my_tab mt, dummy where mt.status = dummy.col1 (+) order by mt.cust_id, mt.payment_id, dummy.rn nulls first; CUST_ID PAYMENT_ID STATUS AMOUNT PAYMENT_DATE 1 1 Applied 100 07/12/2008 1 2 Reversed 200 06/01/2009 1 2 Reversed -200 06/01/2009 1 3 Applied 300 06/01/2009 2 1 Applied 100 07/12/2008 2 2 Reversed 200 05/01/2009 2 2 Reversed -200 05/01/2009 2 3 Applied 300 06/01/2009 2 4 Reversed -400 06/01/2009 2 4 Reversed 400 06/01/2009 2 5 Applied 500 07/01/2009
Published by: Boneist on January 7, 2009 23:10
NB. You may need to mess around with the order if that is not in the order you want. You did not mention what the rules were for all orders expected, so I composed my own * {;-)Also, I added a (cust_id) identifier to differentiate different types of payments, as is usually the case. Remove unless it is not applicable to your case.
-
I am trying to create a new partition in Win7 using the disk management utility. Shrank lecteurC existing to create unallocated space. Am not able to create a simple volume with this space unallocated due to the following error message.
"You cannot create a new volume in this unallocated space because the disk already contains the maximum number of partitions".
How to fix this or go around with another method to create partitions?
Hello
You will need to convert the dynamic disk before creating the extra partition. To do this in disk management:
-Right-click the disk 0 (gray area) which indicates the total size of your hard drive
-Select 'convert to dynamic disk.
Once you have converted to dynamic disk, you will be able to go and create the new simple partition.
I hope this helps.
Best regards, Damian
Damian Coverly
-
I use Photos as a screensaver as described here:It seems that if I have too many image files for the photos as screensaver. After the screen saver slide show has worked for at least 20 minutes, it lags behind trying to leave the screen saver and return to the desktop.What are the specifications of file recommended for use of photos as a screen saver?
- file size in MB (which resembles all default values in C:\Windows\Web\Wallpaper
- dimensions maximum file (which looks like all default values in C:\Windows\Web\Wallpaper
- types of files (extensions)
- maximum number of images supported
When you look at the pictures in my file they all seem to be in the 2 MB and range 1920 x 1200. So my only guess is that having too many is the problem. It does not lag when I change the directory of C:\Windows\Web\Wallpaper. I'm only here a hypothesis, some data of real functional specs would help immensely.Stats of the computerThis built in May 2011 (summer operational solid with zero problems, with the exception of the GAL Photo screen saver when you return to the office)OS: Windows 7 Professional 64-bitCPU: AMD Phenom II X 6 1100 T 3.30 GHzRAM: 16 GB memory DDR3 1600Graphics card: Radeon HD 4670 1 GB 128 - bit DDR3 PCI Express 2.0 x 16Hello
-Did you do changes on the computer before this problem?
Method 1: Run the Microsoft FIXIT from the link and if this resolves the issue.
Fixed problems with Windows Live Photo Gallery that does not
http://support.Microsoft.com/mats/windows_photo_and_slideshow_diag/en-us
Method 2: Follow the steps mentioned below that can help you in the matter of fixing.
(a) open with Windows Explorer %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Themes\(you will find files there are two: TranscodedWallpaper.jpg and slideshow.ini).(b) open slideshow.ini > Remove its content > Save changes.(c) delete TranscodedWallpaper.jpg (you can substitute your own file of that name).(d) restart the computer.(e) re - create the slide show and check if it helps.Method 3: If the problem persists, I suggest to maintain the computer in clean boot mode and check if the problem persists.
A clean boot to check if startup item or services to third-party application is causing this issue.
You can read the following article to configure the computer to boot:
http://support.Microsoft.com/kb/929135
Note: After the troubleshooting steps, see step 7 in binding boot is a way of putting your computer to normal startup mode.Hope this information helps.
-
Hey everybody,
First of all, Yes, I searched through the 8.5 database schema guide. As I went through the scheme, I've developed some ideas on how to collect the data you want. However, if someone has already developed or found the SQL statements (which I'm sure that someone already has) it would help by reducing to the minimum of the buggs in my data collection program.
All these statistics must be grouped by CSQ and selected for a certain time interval (
and ). That is, levels of 1 hour. I have no problem to get a list of results and then perform v.f. to achieve the desired final result. Also, if I need to run several select statements for tables of essentially two join, please include two statements. Finally, I saw the RtCSQsSummary table, but I need to collect data for the past, not at this time. 1 total calls presented by the CSQ
2. total number of calls answered by the CSQ
3 total number of calls abandoned by the CSQ
4. percentage of calls abandoned by CSQ (if it is not stored in the database, I think:
/ ) 5. average abandon time in seconds (if it is not stored in the DB, I think: sum (
) / ) 6. service level - % calls answered in 90 seonds by a set of skills (I have seen metServiceLevel in the ContactQueueDetail table; however, I need to find how to configure this threshold for application)
7. average speed of response by CSQ
8 average conversation by CSQ calls
9. the aggregates connected full-time resources or agents CSQ
10. resources/agents of CSQ ready time
I realize that some of them should be easy to find (as I always am search in the guide of db schema), but I was reading how a new record is created for each step of the call so I could easily see how I could get inaccurate information without properly developed select statements.
Any help will be greatly appreciated.
Brendan
Brendan,
I read your message very well.
You have the schema of database with tables and description. each table has its associated tables (connected with primary and foreign keys). I think you should start the tables to determine what you need.
Cisco uses the stored procedure to prepare the reports. the stored procedure is 'sp_csq_interval' to create the report.
Activity report of Queue Service contact"
HTH
Anas
Please note all useful posts
-
BlackBerry smartphones I used a maximum number of changes PIN and can not recover the Apps?
My blackberry was recently stolen and when I tried recording on my MyWorld/Paypal account I got a notice saying I used the maximum number of changes to the machinery. It is the first time I ever tried to recover my Apps, so I don't understand why I get this message.
I tried to send an email to support, but I kept saying to enter a valid PIN?
He fears a great moment to not be able to recover all my purchased applications.
EDIT: I am with Telus, using the BB Tour 9630.
Hello!
Your request should be sent as follows. Go to this address:
and complete the form. Use, in the "Please select a component:"on the ground, AppWorld billing/payment selection. " Don't forget to also include the reason why you have exceeded your maximum eligible PIN associations to AppWorld (for example, several RMA, warranty replacement, etc..).
If this is the form to which you have received the incorrect PIN code message, please reply back here with this fact... There is another process that you will need to do so that we...
See you soon!
-
Cisco 881 - maximum number of VPN tunnels allowed?
Hello
I know it sounds simple and easy question, but I can't find the answer anywhere - so here it is: -.
I need to know the maximum number of vpn tunnels that can manage a Cisco 881.
(In the context, we have a group of users who work from home and office, so their laptops have the cisco vpn client, I need to know how much of these vpn connections the 881 can manage both before, he died a death)
Host-, I read somewhere a line that State maximum number of users is 20 but believe it was referring to a VOIP service.
Thanks in advance.
The 881 supports 20-tunnel IPSec:
--
Don't stop once you have upgraded your network! Improve the world by lending money to low-income workers:
http://www.Kiva.org/invitedBy/karsteni -
Need help with the use of GROUP BY in a select statement UNION
I am writing a query that allows to combine a legacy system that interfaces it is trial balance in the Oracle of R12 GL. It was only meant to continue for a month or two, but it is likely to continue for 6 months. Please Auditors Auditors, to provide proof that the system is in balance with Oracle GL. By my verification requirements, I need to make a full reconciliation from the month of conversion (life in the amount of date), then PTD for each month.
The legacy account is placed in attribute1 on the lines of the journals. Uses of the old system balancing segments that are also used on the platform in Oracle for this division, i.e., Procure-to-Pay has been cut over Oracle, but not everything yet. So, I can't count on the GL_BALANCES table for the info, I get from the JE_LINES.
My problem is not the only request for the month. But when I try to combine the queries with a Union, to aggregation of each measurement period in its own column, the group is necessary after each selected instruction rather than allowing me to put at the end of the UNION. (When I put the group by at the end of the UNION, I have the 'not one group' function)
So I get duplicate for each month of discrete measure accounts. When I duplicate in my Oracle database accounts, I can't count on the VLOOKUP function in excel to exactly match an account of inheritance. I know there are more sophisticated ways to provide this output, but I'm hoping to get this info in a simple query.
Thank you in advance for any advice you can provide
Example of data output (the goal for me is to get the two rows to appear as one based on common points on the LEGACY_ACCOUNT and the ORACLE ACCOUNT
The LEGACY ACCOUNT ORACLE ACCOUNT JUN_15 JUL_15 AUG_15 SEP_15 OCT_15 NOV_15 DEC_15 010000001109000003584 190-600552-1001-100231-000-0000-0000-0000 0 0 -242961.04 0 0 0 0 010000001109000003584 190-600552-1001-100231-000-0000-0000-0000 0 192588.02 0 0 0 0 0 Here is a simplified version of my code that returns both records. In my research, I had found a number of conversations where it has been shown that the group could be put at the end of the select statement. However, when I remove the group from the first select statement I get SQL error: ORA-00937: not a function of simple-group
Select
l.attribute1 LEGACY_ACCOUNT,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,
JUN_15 TO_NUMBER('0').
JUL_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),
TO_NUMBER('0') AUG_15.
TO_NUMBER('0') SEP_15.
TO_NUMBER('0') OCT_15.
TO_NUMBER('0') NOV_15.
DEC_15 TO_NUMBER('0')
Of
b GL.gl_je_batches,
GL.gl_je_headers h,
GL.gl_je_lines l,
GL.gl_code_combinations c,
GL.gl_je_sources_tl j
where b.je_batch_id = h.je_batch_id
and h.je_header_id = l.je_header_id
and l.code_combination_id = c.code_combination_id
and h.je_source = j.je_source_name
and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)
('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')
and j.language = 'en '.
and h.PERIOD_NAME ("JUL-15'")
Group
l.attribute1,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8
UNION
Select
l.attribute1 LEGACY_ACCOUNT,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | COMBINATION OF C.SEGMENT8,
JUN_15 TO_NUMBER('0').
TO_NUMBER('0') JUL_15.
AUG_15, sum (NVL(l.accounted_dr,0.00)-NVL(l.accounted_cr,0.00)),
TO_NUMBER('0') SEP_15.
TO_NUMBER('0') OCT_15.
TO_NUMBER('0') NOV_15.
DEC_15 TO_NUMBER('0')
Of
b GL.gl_je_batches,
GL.gl_je_headers h,
GL.gl_je_lines l,
GL.gl_code_combinations c,
GL.gl_je_sources_tl j
where b.je_batch_id = h.je_batch_id
and h.je_header_id = l.je_header_id
and l.code_combination_id = c.code_combination_id
and h.je_source = j.je_source_name
and c.segment1 ('190 ', '191', '192', '193', '194', ' 195 ', ' 196',' 197', ' 198 ', ' 199',)
('200 ', '203', ' 205', '206 ', '330', '331', '332',' 333 ', ' 334',' 335', ' 336 ', ' 337')
and j.language = 'en '.
and h.PERIOD_NAME ("AUG-15'")
Group
l.attribute1,
C.SEGMENT1: '-' | C.SEGMENT2: '-' | C.SEGMENT3: '-' | C.SEGMENT4: '-' | C.SEGMENT5: '-' | C.SEGMENT6: '-' | C.SEGMENT7: '-' | C.SEGMENT8
order by 1
Is there a good reason to make this period both as a series of trade unions? This looks like a classic pivot for me query. This will make a way through the tables and should get the desired results.
Select l.attribute1 legacy_account,
c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' | c.segment4: '-' |
c.segment5: '-' | c.segment6: '-' | c.segment7: '-' | combination of c.segment8,
sum (case when h.period_name = 'JUN-15'
then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)
otherwise 0 end) jun_15,.
sum (case when h.period_name = 'JUL-15'
then nvl(l.accounted_dr,0.00)-nvl(l.accounted_cr,0.00)
otherwise 0 end) jul_15,.
- and similar to DEC - 15
GL.gl_je_batches b, gl.gl_je_headers h, gl.gl_je_lines l.
GL.gl_code_combinations c, gl.gl_je_sources_tl j
where b.je_batch_id = h.je_batch_id
and h.je_header_id = l.je_header_id
and l.code_combination_id = c.code_combination_id
and h.je_source = j.je_source_name
and c.segment1 ('190', '191', '192', '193', '194', '195',' 196', ' 197',
'198 ', '199', '200', '203', '205' ', 206',' 330 ', ' 331',
"332 ', '333', '334', '335',' 336 ', ' 337')
and j.language = 'en '.
and h.period_name (' Jun-15', ' 15 JUL', ' AUG-15'... "" ")
L.attribute1 group,
c.Segment1: '-' | c.Segment2: '-' | c.segment3: '-' |
c.segment4: '-' | c.segment5: '-' | c.segment6: '-' |
c.segment7: '-' | c.segment8
If you're on the 11G version of the database, you might want to look at the PIVOT keyword that will do the same thing in a more concise expression.
John
-
How to INSERT a SELECT statement with a GROUP BY clause on a table with an IDENTITY column?
n an application, I intend to truncate and insertion on a 12 c Oracle database, but have found this problem with a
IDENTITY
column. Even if theINSERT... SELECT
statement works on mostSELECT
uses I tried, if this statement was also aGROUP BY
clause, it does not work, delivering a "ORA-00979: not aGROUP BY
expression ' complaint. Some examples of code:create table aux ( owner_name varchar2(20), pet varchar2(20) );
insert into aux values ('Scott', 'dog');
insert into aux values ('Mike', 'dog');
insert into aux values ('Mike', 'cat');
insert into aux values ('John', 'turtle');
create table T1 (
id number generated always as identity,
owner_name varchar2(20),
pet_count number );
select owner_name, count(*) as pet_count from aux group by owner_name; -- works just fine
insert into T1 (owner_name, pet_count) select owner_name, count(*) as pet_count from aux group by owner_name; -- doesn't work
The select statement works by itself, but it fails as an INSERT... SELECT statement.
Appreciate the help!
Looks like a bug. You must open the SR with Oracle. Meanwhile, you could materialize select:
SQL > insert into T1 (owner_name, pet_count)
2 with t as (select / * + materialize * / owner_name, count (*) as pet_count to the owner_name group)
3. Select owner_name, pet_count t
4.3 lines were created.
SQL > select * from t1;
ID OWNER_NAME PET_COUNT
---------- -------------------- ----------
1 John 1
Scott 2 1
3 Mike 2SQL >
Keep in mind index THAT MATERIALIZE is undocumented.
SY.
-
error ora-00036 maximum number of levels of sql recursive (50) exceeded
I have a trigger of the declaration on the LEVELS table, I want to update COMPONENTS field when another field is changed in TIERS, in order to avoid the calculations, I used to ch line shutter COMPONENTS to complete a package, but I get this error ora-00036 maximum number of recursive sql exceeded (50)
It's my trigger:
create or replace trigger DBTRGA_UPD_TIERS
after update on tiers
I INT ;
FOR I IN (PKG_TIERS. TAB. FIRST)... (PKG_TIERS. TAB. Last) LOOP
UPDATE to levels
PUT REFERENCE_EXTERNE = "YYYY"
WHERE LEVELS = PKG_TIERS. TAB (I). I_TIERS;
END LOOP;
end DBTRGA_UPD_TIERS;
This is ma for each trigger line:
create or replace trigger DBTRGA_UPD_TIERS_E
after Update FOR CODE_TYPE_TIERS on LEVELS
for each row
V_CPT INTEGER ;
IF : NEW. CODE_TYPE_TIERS IS NOT NULL THEN
IF PKG_TIERS. TAB. LAST IS NULL THEN
PKG_TIERS. TAB(1). I_TIERS: =: NEW. BLEACHERS;
PKG_TIERS. TAB(1). CODE_TYPE_TIERS: =: NEW. CODE_TYPE_TIERS;
ELSE
V_CPT: = PKG_TIERS. TAB. LAST + 1;
END IF;
END IF;
end DBTRGA_UPD_TIERS_E;
Clearly, you have past of recursion. After updating the table of LEVELS, then a statement trigger level (after update) as the fires that updates the table LEVELS... which will cause then itself to once again fire... which will cause himself to fire once again... which will cause itself to the light again... etc etc.
If it is a business logic that should be implemented, so you don't want to include it as a trigger, you want to just have a code in a package that updates the table once.
If it were me, I would scrap two triggers in this case. Have a trigger is fired for each row updated (in SQL) which has then cross to the PL/SQL package for details of this update line, means you to act so the context switching between SQL and PL/SQL for each update line, which will affect the performance of the updates.
Explain what you're actually trying to do (business logic), with a few examples and data tables and we might be able to propose a better approach, which is not abusing triggers in this way.
Maybe you are looking for
-
Takes too long to Hibernate when I close the lid - also the noise of random device when starting
Hello guys. Since I wiped the machine, I had these two problems. When I close the lid, he used to go to bed right now, but now I see the light of sleep (and the power button), flash and flash, and then he goes to sleep. Upon awakening, he crosses the
-
JOriginal title: can't locate epi.msi When you try to install the update of security essentials KB2691905 I get an error message saying "the component you are trying to use is on a network unavailable resource." «.. . or enter a different path to th
-
I put in new cartridges of HP ink at the address. My printer is still telling me to change the cartridges. I put the old cartridges back in & it worked. Would it be possible that I bought empty cartridges or bad?
-
I CANNOT PRINT E-MAIL IF THE PRINTER PRINT SITES WEB AND EVERYDAY PRINTER PROJECTS
I CAN'T PRINT MY EMAILS
-
I have install "photo login" and it worked several times. There is, then, no. It is no longer opens. After five failed attempts the program amounted to a password of alpanumeic, but I don't think I put a. Q I had to set an alphanumeric password t