Skip to content

Tag: oracle

Oracle SQL to delete the records except last 7 days/1 week

I am using Oracle SQL DB for ERP JD Edwards. Dates are stored in Julian Format for this ERP. We usually use this code to convert date from Julian to normal format. decode(szupmj,0,’ ‘,to_char(to_date(1900000 + olupmj,’YYYYDDD’),’MM/DD/YYYY’)) However we have a requirement w…

How to create an ID column based on condition of previous row?

I am trying to group hospital admission transfers, with the initial index admission. So far I have been able to categorize each admission as ‘index’ or ‘transfer’ based on the time since previous discharge. Now I am trying to group together the admissions together that are in the same …

How to optimize the performance of the following SQL query?

For the following query , I tried creating index on table tmp.req_index_cont_t with columns indcont_key_1 and ind_no but still optimizer is performing full table scan , I am not getting how to resolve this issue , please guide : Answer There’s not enough information here to answer your question. Why do …

Can you help me to correct this query in sql

ERROR at line 1: ORA-00979: not a GROUP BY expression Answer You are getting this error for WEIGHT_IN_PERCENTAGE. If WEIGHT_IN_PERCENTAGE is same for every row in a group you can use (SUM(POINTS) * max(WEIGHT_IN_PERCENTAGE)) or you can SUM(POINTS*WEIGHT_IN_PERCENTAGE) multiply it with POINTS before sum: OR

Returning multiple XML from ref cursor oracle

There is a procedure in the Oracle DB which takes a date range and generates XML file for each day and the return type is ref cursor. When the procedure is called from C# code, I am unable to extract the XML from the cursor. Any pointers will be helpful on how to extract the XML Below given is the