Need help inLOV's in AF Query
Hi,
I need help in adding LOV's in AF Query. Please do the need full.
Regards,
Hi all,
My issue was resolved i have followed the link"http://andrejusb.blogspot.com/2008/11/adf-query-component-and-view-criteria.html"
Regards,
Similar Messages
-
Need help in rewriting a sql query
Can any one please tell me if there is any utility that can help me correcting the sql I have I need to tune the query as its taking lot of time. I want to use some tool that will help me re-formating the query.
Any help in this regard will be highly appreciated.If you think that Oracle SQL Tuning Tools like SQL Tuning Advisor and SQL Access Advisor are not helping.
You might look into thrid party tools like Quest- SQL Navigator and TOAD.
But I don't advise this based on the following:
Re: Oracle Third Party Tools and Oracle Database
Oracle have enough tools of its own to satisfy the various needs.
Adith -
Need help in PO Approval Group Query
Hi,
I need a Query which will list of users that has the Approval Group “BUYER” and “BUYER_DEMO” assigned to them.
It will be needful if anyone provides me the Query
Thanks and RegardsHi
Try this.
SELECT PAPF.employee_number
,PAPF.full_name
FROM po_control_groups_all PCGA
,po_position_controls_all PPCA
,per_all_assignments_f PAAF
,per_all_people_f PAPF
WHERE PCGA.control_group_name IN ('BUYER','BUYER_DEMO')
AND PCGA.control_group_id = PPCA.control_group_id
AND PPCA.position_id = PAAF.position_id
AND PAAF.person_id = PAPF.person_id
Thanks and Regards,
JD -
Need help to re-format the query
Hi All,
Could any one please help me to rewrite this query or explain me how to do it as it is taking 20 mins to execute....
SELECT
AC.ACC_NO||DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.PAYMENT_SET
FROM
MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID= MI.MID AND RELATION='ROF')),MI.PAYMENT_SET)||
DECODE(MI.MSG_CLASS,'ROF', (SELECT LMI2.SERVICE FROM MIF LMI2 WHERE LMI2.MID = (SELECT CHILDMID FROM
MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),MI.SERVICE) HASH_KEY,
MI.MID ,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.PAYMENT_SET FROM MIF LMI2
WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.PAYMENT_SET) PAYMENT_SET,
MI.AMOUNT,
NVL(DECODE(MI.MSG_CLASS,'ROF',MI.CRAMOUNT, MI.DBAMOUNT) ,0) AMT,
AC.ACC_NO,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.BATCH_COMPANY_CD FROM MIF LMI2 WHERE
LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.BATCH_COMPANY_CD) BATCHCOMP,
AC.ACC_ALIAS, NVL(AC.IBAN,
NVL(AC.ACC_ALIAS,AC.ACC_NO)) IBAN_ACCNO,
AC.CURRENCY , AC.ACCOUNTNAME ,
CASE
WHEN (SIGN(MI.PROCESS_DT - TO_DATE(:B2 ,'YYYYMMDD'))) = '1'
THEN 'F'
ELSE 'C' END FUTURE_IND,
(CASE
WHEN (MI.MSG_STATUS = 'CANCELED' OR MI.STATBFHELD = 'CANCELED')
THEN 'C'
WHEN MI.BATCH_PAYMENT_TP = 'RMTRT'
THEN 'R'
WHEN (MI.REJECT_RETURN='REJT' OR MI.MSG_CLASS = 'ROF' OR MI.MSG_STATUS = 'REJECTED')
THEN 'A'
WHEN (MI.REJECT_RETURN='RETN' OR (MI.BATCH_PAYMENT_TP='RTACH' AND MSG_CLASS='ROF'))
THEN 'B'
WHEN MI.MSG_STATUS='FORWARD_PROCESSING'
THEN 'F'
WHEN (MI.MSG_STATUS NOT IN ('COMPLETE','CANCELED','REJECTED') OR (MI.MSG_STATUS='AGED' AND
MI.STATBFHELD NOT IN ('COMPLETE','CANCELED','REJECTED')) )
THEN 'U'
WHEN MI.PROCESS_DT = TO_DATE(:B2 ,'YYYYMMDD')
THEN 'P' END)
PAY_STATUS,
MT.DB_FEE_ACCOUNT_CCY,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM
MESSAGEFREETEXT
WHERE
FIELDNAME ='MANDATEREFERENCE'
AND MESSAGEFREETEXT.MID= MI.MID) MANDREF,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT
WHERE FIELDNAME ='DIRECT_DEBIT_REFERENCE' AND MESSAGEFREETEXT.MID=MI.MID) DDREF,
MT.CUSTOMER_BATCH_REFERENCE LOCINFO,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT WHERE FIELDNAME = 'SECOND_PARTY_ID' AND MESSAGEFREETEXT.MID=MI.MID) SECPRTYINF,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT WHERE FIELDNAME = 'HUB_PAY_PROD_TYP' AND MESSAGEFREETEXT.MID=MI.MID) PAYPRODTYP,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.CHANNEL_REFERENCE FROM MIF LMI2
WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.CHANNEL_REFERENCE) CHNREF,
(SELECT MESSAGEFREETEXT.CONTENTS
FROM MESSAGEFREETEXT
WHERE FIELDNAME = 'CHN_BATCH_REF' AND MESSAGEFREETEXT.MID=MI.MID) CHNBATREF,
TO_CHAR(DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.VALUE_DATE FROM MIF LMI2
WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
RELATION='ROF')),MI.VALUE_DATE),'DD/MM/YYYY') VALUEDT,
DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.ORIG_REFERENCE FROM MIF LMI2 WHERE LMI2.MID = (SELECT
CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),
MI.ORIG_REFERENCE) ORIGREF,
CASE
WHEN (MI.OFFICE <> MI.ORIG_OFFICE)
THEN MT.DR_SIDE_RATE_AM
ELSE
CASE
WHEN MI.DBCURRENCY = MI.CRCURRENCY
THEN
CASE
WHEN MI.CRCURRENCY = :B4
THEN MT.DR_RATE ELSE MT.CR_RATE
END
ELSE
CASE
WHEN MI.CRCURRENCY = :B4
THEN MT.DR_RATE ELSE MT.CR_RATE
END
END
END EXCHRT,
MT.BBK_ADDR1,
MT.BBK_ADDR2,
MT.BBK_ADDR3 ,
MT.BBK ,
MT.BNF_ADDR1,
MT.BNF_ADDR2,
MT.BNF_ADDR3,
MT.BNF_ADDR4 ,
MT.BNF ,
DECODE(MT.BNF_IDCODE,'AC',MT.BNF_ID,' ') ORGBNFID,
DECODE(NVL(MI.ORIG_INSTRUCT_AMOUNT,0),0, MI.ORIG_AMOUNT) ORGINSTAMT,
NVL(TRIM(MI.ORIG_INSTRUCT_CURRENCY), MI.ORIG_CURRENCY) ORGINSTCUR,
CASE
WHEN MOP LIKE 'DRFT%'
THEN 'DD'
WHEN MOP LIKE 'CHEQ%'
THEN 'CO'
WHEN MOP LIKE 'SWIFT'
THEN 'TT'
WHEN MOP LIKE 'DDP%'
THEN 'T'
WHEN MOP LIKE 'BOOK'
THEN 'T' ELSE 'LP'
END PYMTTP,
MT.OBI ,
TO_CHAR(MI.PROCESS_DT,'YYYYMMDD') PROCESSDT,
MI.REFERENCE,
MT.BBK_BIC,
MT.BBK_IDCODE,
DECODE(MT.BBK_IDCODE,'AC',' ',SUBSTR(MT.BBK_ID,1,12)) BBKID,
MI.LOCAL_REF,
MI.CURRENCY INDCURR,
MI.MSG_STATUS,
MI.PK_BATCH_SUBSET,
TO_CHAR(SBBATCH.PROCESS_DT,'YYYYMMDD') SBPROCESSDT,
DECODE(MI.MSG_CLASS,'ROF',MI.CRCURRENCY, MI.DBCURRENCY) DBCURR,
MI.ORIG_REFERENCE ORIGREFRET
FROM
MIF MI,
MTF1000 MT,
ACCOUNTS AC,
( SELECT
MF.PK_BATCH_SUBSET,
MF.PROCESS_DT,
MTF.ORG_ID,
MTF.MP_CR_ACC,
MTF.CR_ACC_NO
FROM
MIF MF,
MTF1000
MTF
WHERE
((MSG_STATUS IN ('COMPLETE','CANCELED','REJECTED')) OR
(MSG_STATUS = 'AGED' AND STATBFHELD IN ('COMPLETE','CANCELED','REJECTED')))
AND
BATCH_MSG_TP = 'S' AND MF.MID = MTF.MID )
SBBATCH
WHERE
MI.MSG_TYPE = :B3
AND MI.PROCESS_DT = TO_DATE(:B2 ,'YYYYMMDD')
AND MI.BATCH_MSG_TP = 'I'
AND DECODE(MI.MSG_CLASS,'ROF',
(SELECT LMI2.SERVICE FROM MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),MI.SERVICE)
IN ('NET','HCN','BIB','LST','MRI')
AND MI.PK_BATCH_EXCH IN (SELECT PK_BATCH_EXCH FROM BATCH_EXCH)
AND MI.MID = MT.MID
AND SBBATCH.PK_BATCH_SUBSET = MI.PK_BATCH_SUBSET
AND TRIM(DECODE(MI.MSG_CLASS,'ROF',MT.CR_ACC_NO, NVL(MT.ORG_ID,NVL(MT.MP_DB_ACC,MT.ACC_NO))) )=AC.ACC_NO
AND AC.OFFICE = :B1
ORDER BY HASH_KEY,PAY_STATUSHi,
please try this.
The first decode or at least part of it repeats at least 7 times.
DECODE(MI.MSG_CLASS,'ROF',
(SELECT LMI2.PAYMENT_SET
FROM MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')
),MI.PAYMENT_SET
||
DECODE(MI.MSG_CLASS,'ROF',
(SELECT LMI2.SERVICE
FROM MIF LMI2 WHERE LMI2.MID =
(SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')
),MI.SERVICE) HASH_KEY,
is similar to this
select mif.* from mif, mfamily where mif.mid=mfamily.childmid
and relation = 'ROF' and msg_class='ROF'
insert it as an inline view and add a conditition
from ...
(select mif.* from mif, mfamily where mif.mid=mfamily.childmid
and relation = 'ROF' and msg_class='ROF') rof
Where ...
and mi.mid=Rof.mid (+)...
and your code above would look like
nvl(rof.payment_set,mi.payment_set) || nvl(rof.service,mi.service) HASH_KEY,
nvl(rof.payment_set,mi.payment_set) PAYMENT_SET
replace all the same decode above with corresponding nvl(...)Hope this helps. -
Need help on Regular expression and query
Hi Guru's, Hope you all are doing great!.
I have a scenario's where i need do insert the data into table.
I have three scenarios :
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
Alex Romano
Kodali,Raj,S
pppppNow what i want is .
1. Alex Romano
if there is space between the string then i want to insert into first name and last name columns
2. Kodali,Raj,S
if its a comma between the string then i want to insert into last name , first name and middle name
3. if there is only one string then same insert into first name and last name.
I wrote the query earlier to handle only comma and now i am trying but not able to use this all scenarios
Can you please help me out.
WITH t AS (
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c))
from
SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
, max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
, max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME
FROM t
CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
GROUP BY str
) ;Currently i am putting a b and c if its null.
Thanks in advance!user590978 wrote:
Hi Guru's, Hope you all are doing great!.
I have a scenario's where i need do insert the data into table.
I have three scenarios :
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
Alex Romano
Kodali,Raj,S
pppppNow what i want is .
1. Alex Romano
if there is space between the string then i want to insert into first name and last name columns
2. Kodali,Raj,S
if its a comma between the string then i want to insert into last name , first name and middle name
3. if there is only one string then same insert into first name and last name.
I wrote the query earlier to handle only comma and now i am trying but not able to use this all scenarios
Can you please help me out.
WITH t AS (
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c))
from
SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
, max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
, max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME
FROM t
CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
GROUP BY str
) ;Currently i am putting a b and c if its null.
Thanks in advance!It's never a popular suggestion, but why not fix the design to begin with?
It's the year 2013, can a client not pass you a "complex" data structure consisting of first, middle and last name?
Why rely on an unreliable construct when there are so many more usable way to achieve this?
Cheers, -
Need help in writing a select query to pull required data from 3 tables.
Hi,
I have three tables EmpIDs,EmpRoles and LatestRoles. I need to write a select Query to get roles of all employees present in EmpIDs table by referring EmpRoles and LatestRoles.
The condition is first look into table EmpRoles and if it has more than one entry for a particular Employee ID than only need to get the Role from LatestRoles other wise consider
the role from EmpRoles .
Sample Script:
Create Table #EmpIDs
(EmplID int )
Create Table #EmpRoles
(EMPID int,Designation varchar(50))
Create Table #LatestRoles
EmpID int,
Designation varchar(50)
Insert into #EmpIDs values (1),(2),(3)
Insert into #EmpRoles values (1,'Role1'),(2,'Role1'),(2,'Role2'),(3,'Role1')
Insert into #LatestRoles values (2,'Role2')
Employee ID 2 is having two roles defined in EmpRoles so for EmpID 2 need to fetch Role from LatestRoles table and for
remaining ID's need to fetch from EmpRoles .
My Final Output of select query should be like below.
EmpID Role
1 Role1
2 Role2
3 Role1
Please help.
MohanMohan,
Can you check if this answers your requirement:
Create Table #EmpIDs
(EmplID int )
Create Table #EmpRoles
(EMPID int,Designation varchar(50))
Create Table #LatestRoles
EmpID int,
Designation varchar(50)
Insert into #EmpIDs values (1)
Insert into #EmpIDs values (2)
Insert into #EmpIDs values (3)
Insert into #EmpRoles values (1,'Role1')
Insert into #EmpRoles values (2,'Role2')
Insert into #EmpRoles values (2,'Role1')
Insert into #EmpRoles values (3,'Role1')
Insert into #LatestRoles values (2,'Role2')
--Method 1
select e.EmplID,MIN(ISNULL(l.Designation,r.Designation)) as Designation
from #empids e
left join #emproles r on e.emplID=r.EmpID
left join #latestRoles l on e.emplID=l.EmpID
group by e.EmplID
--Method 2
;with cte
as
select distinct e.EmplID,r.Designation,count(*) over(partition by e.emplID) cnt
from #empids e
left join #emproles r on e.emplID=r.EmpID
select emplID,Designation
from cte
where cnt=1
UNION ALL
select a.EmplID,l.Designation
from
(select distinct EmplID from cte where cnt>1) a
join #Latestroles l on a.EmplID=l.EmpID
order by emplID
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
Need help in Report From SQL Query
Hi All,
I am facing a problem with a report. I need your help.
I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
I tried also increase the page time out in httpd.conf, but no use.
The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
Please help me to find appropriate reasone for the failure?user602513 wrote:
Hi All,
I am facing a problem with a report. I need your help.
I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
I tried also increase the page time out in httpd.conf, but no use.
The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
Please help me to find appropriate reasone for the failure?Do you get any errors or warnings or it is just the slow speed which is the issue?
There could be a variety of reasons for the delayed processing of this report. That includes parameter settings for that page, cache settings, network configurations, etc.
- explore best optimization for your query;
- evaluate portal for best performance configuration; you may follow this note (Doc ID: *438794.1* ) for ideas;
- third: for that particular page carrying that report, you can use caching wisely. browser cache is neither decent for large files, nor practical. instead, explore the page cache settings that portal provides.
- also look for various log files (application.log and apache logs) if you are getting any warnings reflecting on some kind of processing halt.
- and last but not the least: if you happen to bring up a portal report with more than 10000 rows for display then think about the usage of the report. Evaluate whether that report is good/useful for anything?
HTH
AMN -
Need help in framing an SQL query
Hi ,
Requirement is that
Let’s say I have a table say X
I am passing two input params from UI and in DAO i am querying these input prams against the table X(has c1,c2 as columns ) (as it has two columns mapping the input params A,B from UI).
if either one or Both of the input params matches ,only then i should fetch the records accordingly. It's understood that there won't be a scenario that both input params are null from UI.
I have three conditions here,
1. A match against X, B doesnt Match
2. B match against X, A doesnt Match
3. Both A & B match against X
if i use let's say,
SELECT *FROM X WHERE (c1= A OR c2= B) .
• if A match against X B doesnt Match It is fetching all the records matching A - requirement fullfilled
• B match against X A doesnt Match It is fetching all the records matching B- requirement fullfilled.
• Both A & B match against X It is fetching all the records from the table matching the first condition (which here is A) . requirement not fullfilled.
I am thinking of using the following query but I need to frame it in a way that based on ACHK & BCHK we need to add the conditions.
SELECT CASE WHEN C1 = A THEN 0 ELSE 9 END AS ACHK, CASE WHEN C2 = B THEN 0 ELSE 9 END AS BCHK FROM X
Based on ACHK & BCHK append the conditions. i.e.
IF ACHK = 0 AND BCHK = 0 THEN
AND C1 = A AND C2 = B
ELSE
AND (C1 = A OR C2 = B)
Please help.Hi,
963022 wrote:
Would be glad if you can shed some light on role of DENSE_RANK here (ofcourse i did read the forums but i am confused on what basis a row is ranked).Complicated queries and expressions are usually built of smaller, simpler parts. To understand how the big, complicated thing works, look first at the smaller, simpler components of it, and make sure you understand how they work.
In this case, the query is composed of a sub-query and a main query. Start by looking at the sub-query only. Display all rows and all columns of the sub-query.
Break apart the complicated components of that sub-query. Rnk depends on an ORDER BY clause, but the expression used in that ORDER BY clause isn't displayed anywhere. Copy and display just that expression. (I called this case_1_2 in the query below.) Even that may be too complicated to understand, so break it apart. Case_1_2 is formed by adding 2 smaller CASE expressions; in the query below, I displayed each of the in separate columns (case_1 and case_2).
So here's a query you might use to understand and debug the query I posted:
WITH targets AS
SELECT 'ABC' AS c1, 10 AS c2 FROM dual UNION ALL
SELECT 'ABC', 20 FROM dual UNION ALL
SELECT 'FOO', 10 FROM dual UNION ALL
SELECT 'FOO', 20 FROM dual UNION ALL
SELECT 'FOO', 99 FROM dual
, got_rnk AS
SELECT x.c1, x.c2
, t.c1 AS target_c1
, t.c2 AS target_c2
, DENSE_RANK () OVER ( PARTITION BY t.c1, t.c2
ORDER BY CASE
WHEN x.c1 = t.c1
THEN 1
ELSE 0
END
+ CASE
WHEN x.c2 = t.c2
THEN 2
ELSE 0
END
DESC
) AS rnk
-- ***** DEBUGGING SECTION ***** The following columns are included only
-- to see how the function above works.
, CASE
WHEN x.c1 = t.c1
THEN 1
ELSE 0
END
+ CASE
WHEN x.c2 = t.c2
THEN 2
ELSE 0
END AS case_1_2
, CASE
WHEN x.c1 = t.c1
THEN 1
ELSE 0
END AS case_1
, CASE
WHEN x.c2 = t.c2
THEN 2
ELSE 0
END AS case_2
-- ***** END OF DEBUGGING SECTION *****
FROM targets t
JOIN x ON x.c1 = t.c1
OR x.c2 = t.c2
-- The following main query is only for debugging
SELECT *
FROM got_rnk
ORDER BY target_c1, target_c2
, rnk
;Output:
TARGET TARGET CASE
C1 C2 _C1 _C2 RNK _1_2 CASE_1 CASE_2
ABC 10 ABC 10 1 3 1 2
ZZZ 10 ABC 10 2 2 0 2
ABC 5 ABC 10 3 1 1 0
ABC 6 ABC 10 3 1 1 0
ABC 7 ABC 10 3 1 1 0
ABC 1 ABC 10 3 1 1 0
ABC 3 ABC 10 3 1 1 0
ABC 2 ABC 10 3 1 1 0
ABC 8 ABC 10 3 1 1 0
ABC 9 ABC 10 3 1 1 0
ABC 4 ABC 10 3 1 1 0
ZZZ 20 ABC 20 1 2 0 2
ABC 10 ABC 20 2 1 1 0
ABC 2 ABC 20 2 1 1 0
ABC 1 ABC 20 2 1 1 0
ABC 9 ABC 20 2 1 1 0
ABC 8 ABC 20 2 1 1 0
ABC 7 ABC 20 2 1 1 0
ABC 6 ABC 20 2 1 1 0
ABC 5 ABC 20 2 1 1 0
ABC 4 ABC 20 2 1 1 0
ABC 3 ABC 20 2 1 1 0
ABC 10 FOO 10 1 2 0 2
ZZZ 10 FOO 10 1 2 0 2
ZZZ 20 FOO 20 1 2 0 2Study this output to see how the different components work.
For example, the first 12 rows of output show what we found when we were looking for ('ABC', 10). There were 12 rows in table x that had either ca='ABC' or c2=10 (or both). We used the rnk column to find the best match: lower numbers mean better matches. How did we do that? By using the DENSE_RANK function with a DESCending order by clause, that is, we used <tt> DENSE_RANK () OVER (... ORDER BY exp DESC) </tt>, which means that higher values of exp produce lower values from DENSE_RANK. What is exp? It's the column I called case_1_2. As you can see, when there was a perfect match ('ABC', 10), then case_1_2 had the value 3. Less perfect matches got lower values of case_1_2; for example ('ZZZ', 10) only had 2 in the case_1_2 column, and ('ABC', 5) only had 1. Why did case_1_2 have values of 3, 2 or 1 on those rows? Well, it's the sum of case_1 and case_2, so look at those individual columns, and see how they are computed. -
Need help to write an interesting query
I need some help in framing the query for the following scenario.
I have three tables (in general)
Departments
DNO (PK)
DNAME
Employees
DNO (FK to DNO in Departments)
ENO (PK)
CODE
History
seqid (PK)
ENO (FK to ENO in Employees)
The summary of the data in Employees table looks like below:
DNo No of employees
10 10
20 5
30 8so there will be total of 23 records in employees table. I want to check if all the 10 employees from dept 10 are existing in history table and if exists I want to display the dno and dname from the employees and departments tables respectively. Even if the history table has 9 employees out of 10 from employees table I don't want the query to retrieve that dept details.
Can any one help me with this?
Meanwhile I will also try my level best and let you people know if I come up with anything.
Thanks for your timeHere the example that will help you.
emp_test is the history table for you. You can change ct>9SQL> SELECT * FROM
2 ( SELECT empno ,
3 ename ,
4 e.deptno,dname,
5 COUNT(*) OVER(PARTITION BY e.deptno ORDER BY e.deptno) ct
6 FROM EMP e ,DEPT d
7 WHERE e.deptno=d.deptno
8 AND EXISTS (SELECT 'x' FROM EMP_TEST T
9 WHERE T.empno=e.empno))
10 WHERE ct>3;
EMPNO ENAME DEPTNO DNAME CT
7499 ALLEN 30 SALES 4
7698 BLAKE 30 SALES 4
7654 MARTIN 30 SALES 4
7521 WARD 30 SALES 4
SQL> set linesize 300
SQL> select * from emp_test;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800.2 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7 rows selected.
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800.2 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10formatted
Message was edited by:
devmiral -
Need help with division within a query
Hello all~
I am trying to divide these two columns to get a % of case numbers involving an accident. Im pretty sure you need to use decode to avoid the divide by 0 error but not sure how to implement this within my query. When i run this query below, it gives me the result of "1", which is not correct. Can someone help me please?
Oracle Version 10g
ACCIDENT is a datatype VARCHAR
CASE_NUMBER is a datatype VARCHAR
select to_char(count(ACCIDENT),'999,999,999') as "ACCIDENT",
to_char(COUNT(CASE_NUMBER),'999,999,999')as "CASE NUMBER",
round(ratio_to_report(count(accident))
OVER()*100,2)as "%"
from "PURSUIT"
WHERE ACCIDENT = 'Y'
AND
(:P1_BEG_DATE IS NULL AND :P1_END_DATE IS NULL
OR
pursuit_date BETWEEN to_date(:p1_beg_date,'MM/DD/YYYY') and to_date
(:p1_end_date,'MM/DD/YYYY'))
AND(:P1_TROOP=pursuit.officer_troop OR :p1_troop IS NULL)
AND(:P1_RADIO=pursuit.officer_radio OR :p1_radio IS NULL)
group by case_numberThanks
DeannaAre you sure that the ANDs and ORs in your WHERE clause will take precedence properly?
Also, if you always select only cases where there has been an accident, what percentage would you like to display? Surely in this case the percentage of cases involving in accident in cases where there was an accident.. is 100%?
as a simpler example
SELECT
accident,
ROUND(RATIO_TO_REPORT(count(*)) OVER() * 100)
FROM
pursuit
GROUP BY
accidentHere's a trick to neaten up those IS NULLs:
SELECT
accident,
ROUND(RATIO_TO_REPORT(count(*)) OVER() * 100)
FROM
pursuit
WHERE
pursuit_date >= COALESCE(:p1_beg_date, pursuit_date) AND
pursuit_date <= COALESCE(:p1_end_date, pursuit_date) AND
officer_troop LIKE :p1_troop AND
offcier_radio LIKE :p1_radio
GROUP BY
accidentTo wildcard a date, simply pass NULL in; the coalesce will replace the null with the pursuit_date from the record (thus the >= and <= becomes true)
To wildcard the troop or the radio, simply pass a '%' symbol as the value of the parameter. If the front end code is already set up to pass nulls, use the COALESCE trick above -
Need help to change BO generated query at universe leavel
Hi
Is there any possiblity to change sql at universe leavel.Kindly help me i am new to designer.
The below is the BO generated query.
SELECT specObjID
FROM SpecObj
WHERE SpecClass = dbo.fSpecClass('UNKNOWN')
Users are not intrested to go for coustomised sql in report leavel.
I need to change the above sql accordingly due to some performance issues.
The feilds that specify in the where clause SpecClass = dbo.fSpecClass('UNKNOWN') move to from clause.
Like below
SELECT specObjID
FROM SpecObj ,SpecClass = dbo.fSpecClass('UNKNOWN')
WHERE
Kindly suggest me greatly appriciated.
Thanks.
RajHI,
As per your expectation query like below is not possible to give condition in from clause as per my understand,
SELECT specObjID
FROM SpecObj ,SpecClass = dbo.fSpecClass('UNKNOWN')
WHERE
I think your expected result can be achieved by giving condition while creating the object SpecObj.
Steps:
Go to universe, then edit the object SpecObj there you can give the where clause condition
WHERE SpecClass = dbo.fSpecClass('UNKNOWN')
This will increase your performance.
Regrds,
Ragoth.C -
Need Help in tuning of the query
Hi all,
Can any body help me how we can rewrite this query in
optimized way.
SELECT A.C1 AS COLUMN_1, B.C2 AS COLUMN_2
FROM A,B
WHERE A.C1 IN (
SELECT COLUMN_1 FROM(
(SELECT A.C1 AS COLUMN_1,
COUNT(C1) AS COUNT,
RANK() OVER (ORDER BY COUNT(C1) DESC) AS RANK
FROM A, B, C
WHERE A.C1 = B.C3
AND B.C2 = C.C1
AND <other conditions>
GROUP BY A.C1)
WHERE RANK <= 10)
AND A.C1 = B.C3
AND <other conditions>
ORDER BY A.C1
I am using <other conditions> are same in outer query and inner query also.
Thanks in Advance,Hi,
Yes exactly I am looking TOP-10 results the query is like this
SELECT A.C1 AS COLUMN_1, B.C2 AS COLUMN_2
FROM A,B
WHERE B.C2 IN (
SELECT COLUMN_1 FROM(
(SELECT B.C2 AS COLUMN_1,
COUNT(A.C1) AS COUNT,
RANK() OVER (ORDER BY COUNT(C1) DESC) AS RANK
FROM A, B, C
WHERE A.C1 = B.C3
AND B.C2 = C.C1
AND <other conditions>
GROUP BY B.C2)
WHERE RANK <= 10)
AND A.C1 = B.C3
AND <other conditions>
ORDER BY B.C2
Thanks -
Need Help with Creating the SQl query
Hi,
SQL query gurus...
INFORMATION:
I have two table, CURRENT and PREVIOUS.(Table Defs below).
CURRENT:
Column1 - CURR_PARENT
Column2 - CURR_CHILD
Column3 - CURR_CHILD_ATTRIBUTE 1
Column4 - CURR_CHILD_ATTRIBUTE 2
Column5 - CURR_CHILD_ATTRIBUTE 3
PREVIOUS:
Column1 - PREV_PARENT
Column2 - PREV_CHILD
Column3 - PREV_CHILD_ATTRIBUTE 1
Column4 - PREV_CHILD_ATTRIBUTE 2
Column5 - PREV_CHILD_ATTRIBUTE 3
PROBLEM STATEMENT
Here the columns 3 to 5 are the attributes of the Child. Lets assume that I have two loads, One Today which goes to the CURRENT table and one yesterday which goes to the PREVIOUS table. Between these two loads there is a CHANGE in the value for Columns either 3/4/5 or all of them(doesnt matter if one or all).
I want to determine what properties for the child have changed with the help of a MOST efficient SQL query.(PARENT+CHILD is unique key). The Database is ofcourse ORACLE.
Please help.
Regards,
ParagHi,
The last message was not posted by the same user_name that started the thread.
Please don't do that: it's confusing.
Earlier replies give you the information you want, with one row of output (maximum) per row in current_tbl. There may be 1, 2 or 3 changes on a row.
You just have to unpivot that data to get one row for every change, like this:
WITH single_row AS
SELECT c.curr_parent
, c.curr_child
, c.curr_child_attribute1
, c.curr_child_attribute2
, c.curr_child_attribute3
, DECODE (c.curr_child_attribute1, p.prev_child_attribute1, 0, 1) AS diff1
, DECODE (c.curr_child_attribute2, p.prev_child_attribute2, 0, 2) AS diff2
, DECODE (c.curr_child_attribute3, p.prev_child_attribute3, 0, 3) AS diff3
FROM current_tbl c
JOIN previous_tbl p ON c.curr_parent = p.prev_parent
AND c.curr_child = p.prev_child
WHERE c.curr_child_attribute1 != p.prev_child_attribute1
OR c.curr_child_attribute2 != p.prev_child_attribute2
OR c.curr_child_attribute3 != p.prev_child_attribute3
, cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 3
SELECT s.curr_parent AS parent
, s.curr_child AS child
, CASE c.n
WHEN 1 THEN s.curr_child_attribute1
WHEN 2 THEN s.curr_child_attribute2
WHEN 3 THEN s.curr_child_attribute3
END AS attribute
, c.n AS attribute_value
FROM single_row s
JOIN cntr c ON c.n IN ( s.diff1
, s.diff2
, s.diff3
ORDER BY attribute_value
, parent
, child
; -
Need help in writing SP notification Query
Hi,
My purpose of writing a query is to restrict a user to add journal entry in case account code lies in Expense Drawer and Cost Center Code is not in user define range.
Please help me on this:-
IF (@object_type = '30' AND (@transaction_type = 'A' Or @transaction_type = 'U'))
BEGIN
Declare @AccountCodeMaster as Nvarchar(20)
Declare @AccountonDocument as Nvarchar(20)
Declare @ProfitCentreMaster as Nvarchar(20)
Declare @ProfitCentreOnDocument as Nvarchar(20)
Set @AccountCodeMaster = (select AcctCode from oact where GroupMask = 5)
Set @AccountonDocument = (Select Account from jdt1 where TransId = @list_of_cols_val_tab_del)
Set @ProfitCentreMaster = (select PrcCode from ocr1 where PrcCode >= 91100001 and PrcCode <= 91921001)
Set @ProfitCentreOnDocument = (select ProfitCode from jdt1 where TransId = @list_of_cols_val_tab_del)
if (@AccountonDocument) in (@AccountCodeMaster) and (@ProfitCentreOnDocument) not in (@ProfitCentreMaster)
Begin
set @error =1
set @error_message = 'Profit Center is wrong,Please select the right profit Center else Consult to Finance Department'
End
END
ThanksHi,
Welcome you post on the forum.
You may try:
IF (@object_type = '30' AND @transaction_type in ('A', 'U')
BEGIN
If Exists (Select T0.Account from jdt1 T0 inner join oact T1 ON T1.AcctCode=T0.Account AND T1.GroupMask = 5
where T0.TransId = @list_of_cols_val_tab_del AND T0.ProfitCode NOT IN (select PrcCode from ocr1 where PrcCode >= 91100001 and PrcCode <= 91921001))
Begin
set @error =1
set @error_message = 'Profit Center is wrong,Please select the right profit Center else Consult to Finance Department'
End
END
Thanks,
Gordon -
Need help how to change LOV query
Hi All,
Can some one help me how to use the LOV Query based on responsibility (I am using form personalization)
When the user logs in with XX_Payables Super user with say (Responsibility id =500) then the LOV should be
Select BA.bank_account_name,
BA.bank_account_num,
BA.bank_Account_id,
BA.currency_code bank_currency_code,
from CE_BANK_ACCOUNTS ba
but if the user logs in with any other responsibilits then the lov should be
Select BA.bank_account_name,
BA.bank_account_num,
BA.bank_Account_id,
BA.currency_code bank_currency_code,
from CE_BANK_ACCOUNTS ba
where BA.multi_currency_allowed_flag = 'Y'
step 1
I have created a built in builtin type : Create Record group from query
Arugument : Select statement
Group name : XX_Group
step 2
Property
Object type : LOV
target object : PAY_ACTIVE_BANK_ACCOUNTS
property name : Group name
value XX_GROUP
Using this method i am able to select only one query
How can i control this based on responsibility.
Appreciate if some one can help me to resolve this issue.
Regards,
RajiniThanks for your reply, I tried to use this query but i am getting error as FRM-41076 Error populating group and FRM-41072 Cannot create group
but if i use any one of the query or either of the query it works fine. but i dont see any issues when i run only any one of the query in argument in form personalization. Union all is returing rows in database.
SELECT BA.bank_account_name,
BA.bank_account_num,
BA.bank_Account_id,
BA.currency_code bank_currency_code,
CBAU.bank_acct_use_id ,
BA.multi_currency_allowed_flag bank_multi_currency_flag,
BA.zero_amount_allowed bank_zero_amounts_allowed,
BA.account_owner_org_id legal_entity_id,
CBB.bank_name,
CBB.bank_branch_name
FROM
CE_BANK_ACCOUNTS BA,
CE_BANK_BRANCHES_V CBB,
CE_BANK_ACCT_USES_OU_V CBAU
WHERE ((BA.multi_currency_allowed_flag = 'Y' AND
(BA.currency_code = :pay_sum_folder.functional_currency_code or
BA.currency_code = :parameter.pay_in_full_currency_code )) or
BA.currency_code = nvl( :parameter.pay_in_full_currency_code, BA.currency_code))
AND CBAU.BANK_ACCOUNT_ID = BA.BANK_ACCOUNT_ID
AND sysdate between TRUNC(CBB.start_date) and nvl(TRUNC(CBB.end_date), sysdate + 1)
AND CBB.branch_party_id = BA.bank_branch_id
AND SYSDATE < NVL(BA.END_DATE,SYSDATE+1)
AND BA.ACCOUNT_CLASSIFICATION = 'INTERNAL'
AND CBAU.ap_use_enable_flag = 'Y'
AND CBAU.org_id = :pay_sum_folder.org_id
AND NVL(BA.netting_acct_flag, 'N') <> 'Y'
AND fnd_global.resp_name = 'XX PAYABLES SUPER USER'
AND CBB.bank_name_alt = 'Head office bank'
UNION ALL
SELECT BA.bank_account_name,
BA.bank_account_num,
BA.bank_Account_id,
BA.currency_code bank_currency_code,
CBAU.bank_acct_use_id ,
BA.multi_currency_allowed_flag bank_multi_currency_flag,
BA.zero_amount_allowed bank_zero_amounts_allowed,
BA.account_owner_org_id legal_entity_id,
CBB.bank_name,
CBB.bank_branch_name
FROM
CE_BANK_ACCOUNTS BA,
CE_BANK_BRANCHES_V CBB,
CE_BANK_ACCT_USES_OU_V CBAU
WHERE ((BA.multi_currency_allowed_flag = 'Y' AND
(BA.currency_code = :pay_sum_folder.functional_currency_code or
BA.currency_code = :parameter.pay_in_full_currency_code )) or
BA.currency_code = nvl( :parameter.pay_in_full_currency_code, BA.currency_code))
AND CBAU.BANK_ACCOUNT_ID = BA.BANK_ACCOUNT_ID
AND sysdate between TRUNC(CBB.start_date) and nvl(TRUNC(CBB.end_date), sysdate + 1)
AND CBB.branch_party_id = BA.bank_branch_id
AND SYSDATE < NVL(BA.END_DATE,SYSDATE+1)
AND BA.ACCOUNT_CLASSIFICATION = 'INTERNAL'
AND CBAU.ap_use_enable_flag = 'Y'
AND CBAU.org_id = :pay_sum_folder.org_id
AND NVL(BA.netting_acct_flag, 'N') <> 'Y'
AND fnd_global.resp_name != 'XX PAYABLES SUPER USER'
Maybe you are looking for
-
how do I share files between profiles on my Macbook Pro. 10.8.4 I have moved the files to the public folder, shared the folder and enabled sharing in system preferences. however, i still cannot access the files from my other profile. Please help!
-
Unable to delete the files from CSV volumes on HyperV Cluster
Hello There, I have a HyperV failover cluster with CSV Volumes recently i moved some of the VMs to another cluster. VMs are moved but i still have the VM files on the CSV volumes which are occupying the disk space i tried to delete the VHD files / VM
-
Do I need to download any antivirus Program for IPad 2, which program is better?
Do I need to download any antivirus Program for IPad 2, which program is better?
-
IPhone 4 Battery life suddenly dropped by half
Hi Everyone, I have a 3 month old iPhone 4 running IOS 4.2.1 since it became available. The battery had been performing fine till 2 days ago. Now I start out with it fully charged in the morning and the battery had died at 2pm in the afternoon when a
-
My iTunes 7 works but the GUI is garbled. As a player it seems to be working fine, but the screens are unusable. I thought it was perhaps my Mac mini's (Tiger) graphic card's limitation, but yesterday I installed iTunes 7 on an old G3 iBook (Panther)