Help required in HRMS query
Hello friends ,
I am trying to find the parent competence from competency elements , in per_competence_elements table we have
column named PARENT_COMPETENCE_ELEMENT_ID , now how to find the parent competency , which table should i use ??
Any suggestions please ?
Regards ,
--Keerthi
Hey Giuseppe ,
Thanks so much , but how do i get the parent competency name , i'm quite new to this technology . can explain in detail if possible .
Also can you guys tell me how to attach child competency to parent competency from Oracle application ( front end ) , which screen should i
access ??
--keerthi
Similar Messages
-
I have a table and cols as below:
START DATE TOTAL DAYS
10/11/2011 15:00 1
10/15/2011 5:00 1
12/22/2011 10:00 1
12/22/2011 11:00 2
12/30/2011 10:00 1
1/1/2012 1:00 1
1/1/2012 10:00 1
1/1/2012 16:00 2
1/2/2012 14:00 1
1/3/2012 15:00 1
1/4/2012 15:00 2
1/4/2012 18:00 1
I need to query where the values from the above table
should return values like below:
I tried many ways but could not find suitable solution.
Kindly help me in this regard.
START DATE TOTAL DAYS
10/11/2011 15:00 1
10/15/2011 5:00 1
12/22/2011 11:00 2
12/30/2011 10:00 1
1/1/2012 16:00 2
1/2/2012 14:00 1
1/3/2012 15:00 1
1/4/2012 15:00 2
ultimate goal is to sum up the all numbers TOTAL DAYS column in the second table... All task should be handled in single query. I cannot use java coding to handle this as my requirement needs to be included in the query which exists already.
Edited by: 915175 on Feb 16, 2012 11:02 PMselect trunc(start_date), max(start_date), max(total_days) from tablename
group by trunc(start_date);Please check below Test done at my local site with you data:
SQL>
SQL> with tablename as
2 (
3 select to_date('10/11/2011 15:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
4 select to_date('10/15/2011 5:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
5 select to_date('12/22/2011 10:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
6 select to_date('12/22/2011 11:00' , 'mm/dd/yyyy hh24:mi') start_date, 2 total_days from dual union all
7 select to_date('12/30/2011 10:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
8 select to_date('1/1/2012 1:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
9 select to_date('1/1/2012 10:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
10 select to_date('1/1/2012 16:00' , 'mm/dd/yyyy hh24:mi') start_date, 2 total_days from dual union all
11 select to_date('1/2/2012 14:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
12 select to_date('1/3/2012 15:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual union all
13 select to_date('1/4/2012 15:00' , 'mm/dd/yyyy hh24:mi') start_date, 2 total_days from dual union all
14 select to_date('1/4/2012 18:00' , 'mm/dd/yyyy hh24:mi') start_date, 1 total_days from dual
15 )
16 select TO_CHAR(max(start_date),'MM/DD/YYYY HH24:MI') start_date , max(total_days) total_days from tablename
17 group by trunc(start_date);
START_DATE TOTAL_DAYS
10/15/2011 05:00 1
01/03/2012 15:00 1
12/30/2011 10:00 1
01/01/2012 16:00 2
10/11/2011 15:00 1
12/22/2011 11:00 2
01/04/2012 18:00 2
01/02/2012 14:00 1
8 rows selected.
SQL>Regards,
Dipali..
Update: Added test done at my database..
Edited by: Dipali Vithalani on Feb 16, 2012 11:18 PM -
Help Required(Rewriting the query to reduce steps)
With and Without Group ID,I am populating a value into a column,Can anyone please help to write the same query in an other way.This is a sample column.Likewise,there are 5 more columns to be populated.So that I have to write 2 left outer joins for a single column with a little difference.
SELECT
CASE
WHEN T6.ACTUAL_FUNCTION IS NOT NULL
THEN T6.ACTUAL_FUNCTION
WHEN T10.ACTUAL_FUNCTION IS NOT NULL
THEN T10.ACTUAL_FUCNTION
ELSE T5.ACTUAL_FUCNTION
END AF_NOM_PRE_GTEES
FROM
ABC_WT17 T1
INNER JOIN
ABC_CUSTOMER_WT01 T3
ON T1.ORIGINAL_SDS_PARTY_IDR=T3.ORIGINAL_SDS_PARTY_IDR
AND T1.IDR_TYPE_CODE=T3.IDR_TYPE_CODE
LEFT OUTER JOIN /* This is the condition with group ID*/
RESIDUAL_CONTROL T6
ON
T1.NOM_PRE_GTEES = T6.VALUE_MAX
OR
T1.NOM_PRE_GTEES > T6.VALUE_GREATER_THAN
AND
T1.NOM_PRE_GTEES < T6.VALUE_MAX
AND
_ T1.GROUP_ID = T6.GROUP_ID_
AND
T6.FALLBACK_IND = ‘N’
LEFT OUTER JOIN /* this is the condition without Group ID*/
RESIDUAL_CONTROL T10
ON
T1.NOM_PRE_GTEES = T10.VALUE_MAX
OR
T1.NOM_PRE_GTEES > T10.VALUE_GREATER_THAN
AND
T1.NOM_PRE_GTEES < T10.VALUE_MAX
AND
T10.FALLBACK_IND = ‘N’
CROSS JOIN
RESIDUAL_CONTROL T5
ON T5.FALLBACK_IND = ‘Y’
Thanks in advance.KVB wrote:
With and Without Group ID,I am populating a value into a column,Can anyone please help to write the same query in an other way.This is a sample column.Likewise,there are 5 more columns to be populated.So that I have to write 2 left outer joins for a single column with a little difference.
SELECT
CASE
WHEN T6.ACTUAL_FUNCTION IS NOT NULL
THEN T6.ACTUAL_FUNCTION
WHEN T10.ACTUAL_FUNCTION IS NOT NULL
THEN T10.ACTUAL_FUCNTION
ELSE T5.ACTUAL_FUCNTION
END AF_NOM_PRE_GTEES
FROM
ABC_WT17 T1
INNER JOIN
ABC_CUSTOMER_WT01 T3
ON T1.ORIGINAL_SDS_PARTY_IDR=T3.ORIGINAL_SDS_PARTY_IDR
AND T1.IDR_TYPE_CODE=T3.IDR_TYPE_CODE
LEFT OUTER JOIN /* This is the condition with group ID*/
RESIDUAL_CONTROL T6
ON
T1.NOM_PRE_GTEES = T6.VALUE_MAX
OR
T1.NOM_PRE_GTEES > T6.VALUE_GREATER_THAN
AND
T1.NOM_PRE_GTEES < T6.VALUE_MAX
AND
_ T1.GROUP_ID = T6.GROUP_ID_
AND
T6.FALLBACK_IND = ‘N’
LEFT OUTER JOIN /* this is the condition without Group ID*/
RESIDUAL_CONTROL T10
ON
T1.NOM_PRE_GTEES = T10.VALUE_MAX
OR
T1.NOM_PRE_GTEES > T10.VALUE_GREATER_THAN
AND
T1.NOM_PRE_GTEES < T10.VALUE_MAX
AND
T10.FALLBACK_IND = ‘N’
CROSS JOIN
RESIDUAL_CONTROL T5
ON T5.FALLBACK_IND = ‘Y’
Thanks in advance.Thread: HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting -
Help required writing a query!
Dear All,
My database is 11gR2 on Linux.
I have data like this:
ID Name
1 Mike
2 Mike Peter
3 Steven
4 Steven Andrew
In a select query I want to get the output
1 Mike
3 Steven
Logic, if it find next match for like for the first name, skip record, even if it contains second name
Kindly help.
Regards, ImranHi Imran,
This is defintely not a nobel price, but it returned what your specified.
WITH t1
AS (SELECT 1 AS id, 'Mike' AS name FROM DUAL UNION
SELECT 2, 'Mike Peter' FROM DUAL UNION
SELECT 3, 'Steven' FROM DUAL UNION
SELECT 4, 'Steven Andrew' FROM DUAL)
SELECT *
FROM t1
WHERE name IN (SELECT SUBSTR (name, 1, INSTR (name, ' ', 1) - 1) FROM t1)HTH,
Thierry -
sir
below query runs fine
but the probblem is...i am not able to display the figures in the format '999999.99'
Also please guide me as to make the query short... can i use cursors here?
i am using 10g
select
LBRCODE branch,
trim(substr(PRDACCTID,1,8)) product,
sum(case when totsanclimit between 0 and 200000 then
(Case when hrk in (13,14) THEN
(CASE WHEN bal4 !=0 THEN 1 else 0 END )
ELSE
(CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
END )
else 0 end )as "bktCount-1",
SUM( CASE WHEN TOTSANCLIMIT between 0 and 200000 then
(Case when hrk in (13,14) THEN
to_number(to_char(bal4,'99999999999.99'))
else
to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
END )
ELSE
0 end) AS"Bkt_1",
sum(case when totsanclimit between 200001 and 1000000 then
(Case when hrk in (13,14) THEN
(CASE WHEN bal4 !=0 THEN 1 else 0 END )
ELSE
(CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
END )
else 0 end )as "bktCount-2",
SUM(
CASE WHEN TOTSANCLIMIT between 200001 and 1000000
then
(Case when hrk in (13,14) THEN
to_number(to_char(bal4,'99999999999.99'))
else
to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
END )
ELSE 0 end) AS"Bkt_2",
sum(case when totsanclimit between 1000001 and 5000000 then
(Case when hrk in (13,14) THEN
(CASE WHEN bal4 !=0 THEN 1 else 0 END )
ELSE
(CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
END )
else 0 end )as "bktCount-3",
SUM(
CASE WHEN TOTSANCLIMIT between 1000001 and 5000000
then
(Case when hrk in (13,14) THEN
to_number(to_char(bal4,'99999999999.99'))
else
to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
END )
ELSE 0 end) AS"Bkt_3",
sum(case when totsanclimit between 5000001 and 10000000 then
(Case when hrk in (13,14) THEN
(CASE WHEN bal4 !=0 THEN 1 else 0 END )
ELSE
(CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
END )
else 0 end )as "bktCount-4",
SUM(
CASE WHEN TOTSANCLIMIT between 5000001 and 10000000
then
(Case when hrk in (13,14) THEN
to_number(to_char(bal4,'99999999999.99'))
else
to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
END )
ELSE 0 end) AS"Bkt_4",
sum(case when totsanclimit BETWEEN 10000001 AND 200000000 then
(Case when hrk in (13,14) THEN
(CASE WHEN bal4 !=0 THEN 1 else 0 END )
ELSE
(CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
END )
else 0 end )as "bktCount-5",
SUM(
CASE WHEN TOTSANCLIMIT BETWEEN 10000001 AND 200000000
then
(Case when hrk in (13,14) THEN
to_number(to_char(bal4,'99999999999.99'))
else
to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
END )
ELSE 0 end) AS"Bkt_5",
sum(case when totsanclimit > 200000000 then
(Case when hrk in (13,14) THEN
(CASE WHEN bal4 !=0 THEN 1 else 0 END )
ELSE
(CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
END )
else 0 end )as "bktCount-6",
SUM(
CASE WHEN TOTSANCLIMIT > 200000000
then
(Case when hrk in (13,14) THEN
to_number(to_char(bal4,'99999999999.99'))
else
to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
END )
ELSE 0 end) AS"Bkt_6",
--total
sum(
(Case when hrk in (13,14) THEN
(CASE WHEN bal4 !=0 THEN 1 else 0 END )
ELSE
(CASE WHEN BAL1-(BAL4-BAL5)!=0 THEN 1 ELSE 0 END)
end)
)as "TotCount-7",
SUM((Case when hrk in (13,14) THEN
to_number(to_char(bal4,'99999999999.99'))
else
to_char(BAL1,'99999999999.99')-(to_char(BAL4,'99999999999.99')-to_char(BAL5,'99999999999.99'))
END )
) AS"Total"
from
select
q1.lbrcode,q1.prdacctid,q1.totsanclimit,q2.balance1,balance3,balance4,balance5,balance6,balance7,q3.hrk
FROM
SELECT LBRCODE,PRDACCTID,SANCDATE,TOTSANCLIMIT,RNK FROM
SELECT
LBRCODE,
PRDACCTID,
EFFFROMDATE,
CURCD,
PLRLINKYN,
SANCAUTHORITY,
SANCDATE,
TOTSANCLIMIT,
RANK() OVER (PARTITION BY LBRCODE,PRDACCTID ORDER BY EFFFROMDATE DESC) AS RNK
FROM LIMIT_MAST
WHERE LBRCODE IN (3)
-- AND PRDACCTID LIKE 'PLLN %'
WHERE RNK=1
)Q1,
(SELECT LBRCODE,PRDACCTID,CBLDATE,BALANCE1,BALANCE2,BALANCE3,BALANCE4,BALANCE5,BALANCE6,BALANCE7 FROM
( SELECT TRN_MAST.*,
RANK() OVER(PARTITION BY LBRCODE,PRDACCTID ORDER BY CBLDATE DESC) AS HRK
FROM TRN_MAST
WHERE CBLDATE <= TO_DATE('31-MAR-2008','DD-MON-RR')
AND (LBRCODE,TRIM(SUBSTR(PRDACCTID,1,8))) IN (SELECT LBRCODE,TRIM(PRDCD) FROM PRD_MAST
WHERE MODULETYPE IN (13,14,30))
)WHERE HRK=1
)Q2,
( SELECT LBRCODE,TRIM(PRDCD) prd,MODULETYPE hrk FROM PRD_MAST
WHERE (LBRCODE,TRIM(PRDCD)) IN
(SELECT LBRCODE,TRIM(SUBSTR(PRDACCTID,1,8)) FROM LIMIT_MAST)
)q3
WHERE Q1.LBRCODE=Q2.LBRCODE
AND Q1.PRDACCTID=Q2.PRDACCTID
AND TRIM(SUBSTR(Q2.PRDACCTID,1,8))=q3.PRD
AND Q1.LBRCODE=q3.LBRCODE
group by lbrcode,trim(substr(prdacctid,1,8))
order by lbrcode
/Like this?
SQL> select 123456 my_num from dual;
MY_NUM
123456
SQL>
SQL> column my_num format 999999.99
SQL>
SQL> select 123456 my_num from dual;
MY_NUM
123456.00
SQL>Asif Momen
http://momendba.blogspot.com -
Hi,
I am sure this is not a very complex query but i am out of ideas today and so decided to post it. Here is my SQL:
select cr.id, ri.report_name
from category cr, report ri where ri.report_id = cr.id
and
cr.id in ('AC01','UP01','UP02','UP03','XD01','UP04','ED01','EB01','ES01','DL01','UV01');
I would like my output to appear in the same format as is specified in the IN clause i.e. first 'AC01' then 'UP01' then 'UP02' then 'UP03' and so forth.
Thanks in advance.Then your order by should be like this
ORDER BY DECODE(cr.id, 'AC01', 1, 'UP01', 2, 'UP02', 3, 'UP03', 4, 'XD01', 5, 'UP04', 6, 'ED01', 7, 'EB01', 8, 'ES01', 9, 'DL01', 10, 'UV01', 11) -
Urgent help required: Query regarding LC Variables
Hi All
Sometime earlier I was working on a performance issue raised by a customer. It was shell script that was taking almost 8-9 hrs to complete. During my research I came across a fact that there were some variables which were not set, the LC variables were impacting the sort funnel operations because of which the script was taking a long time to execute.
I asked them to export the following commands, after which the program went on smoothly and finished in a couple of mins:
export LC_COLLATE=en_US.ISO8859-1
export LC_MESSAGES=C
export LC_MONETARY=en_US.ISO8859-1
export LC_MONETARY=en_US.ISO8859-1
export HZ=100
export LC_CTYPE=en_US.ISO8859-1
export LANG=en_US.UTF-8
Later I did recover that setting the LC_COLLATE to C, is not helping and the program was again taking a lot of time. Few questions that I want to ask are:
1. Can someone please tell me, what each of these variable mean and how these values make a difference.
2. When I exported LC_COLLATE=en_US.ISO8859-1, it worked fine, but when i tried with the defalut value LC_COLLATE=C, then why the program didnt work.
As this issue is still going on, hence I would request All to provide their valuable inputs and let me know as much as possible.
Appreciate your help in this regard.
Thanks
Amit
Hi All
A new development in this regard. The customer has send us a screen shot in which they were trying to export the locale variable using the commands which I have pasted above. I can see in the screen shot that while exporting LC_COLLATE and LC_TYPE, they get a message that ""ksh: export: couldn't set locale correctly"".
Request everyone to please give their inputs as it's a bit urgent.
Thanks for all the help in advance.
Thanks
Amit
Some help required please...
Edited by: amitsinhaengg on Jul 22, 2009 2:03 AM
Edited by: amitsinhaengg on Jul 22, 2009 2:06 AMLC_CTYPE
Controls the behavior of character handling functions.
LC_TIME
Specifies date and time formats, including month names, days of the week, and common full and abbreviated representations.
LC_MONETARY
Specifies monetary formats, including the currency symbol for the locale, thousands separator, sign position, the number of fractional digits, and so forth.
LC_NUMERIC
Specifies the decimal delimiter (or radix character), the thousands separator, and the grouping.
LC_COLLATE
Specifies a collation order and regular expression definition for the locale.
LC_MESSAGES
Specifies the language in which the localized messages are written, and affirmative and negative responses of the locale (yes and no strings and expressions).
You can use command
# locale -k LC_CTYPE
to see more detail about each type. -
i have a table
source table :
create table order(name_a varchar2(100),intid number);
insert into order values('a',1);
insert into order values('b',1);
insert into order values('c',1);
insert into order values('d',1);
insert into order values('e',2);
insert into order values('f',2);
insert into order values('g',2);
i need a query , which result in the below output :
if i look for intid=1 the query should give a,b,c,d
if i look for intid=2 the query should give f,g
ThanksHi,
781649 wrote:
i have a table
source table :
create table order(name_a varchar2(100),intid number);
insert into order values('a',1);
insert into order values('b',1);
insert into order values('c',1);
insert into order values('d',1);
insert into order values('e',2);
insert into order values('f',2);
insert into order values('g',2);Thanks for posting the CREATE TABLE and INSERT statements; it's very helpful.
i need a query , which result in the below output :
if i look for intid=1 the query should give a,b,c,d
if i look for intid=2 the query should give f,gDid you mean <b>e</b>,f,g ?
That's called String Aggregation , and how to do it depends on your version of Oracle, and your exact requirements.
See thie following page for several techniques:
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
If you're using Oracle 10 (or higher), and it's important that the name_a's be in order in the output, then you can do this:
WITH got_r_num AS
SELECT name_a
, intid
, ROW_NUMBER () OVER ( PARTITION BY intid
ORDER BY name_a
) AS r_num
FROM order_table -- ORDER is not a good table name
WHERE intid IN (1) -- Optional
SELECT intid
, SUBSTR ( SYS_CONNECT_BY_PATH (name_a, ',')
, 2
) AS name_a_list
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
START WITH r_num = 1
CONNECT BY r_num = PRIOR r_num + 1
AND intid = PRIOR intid
;Starting in Oracle 11.2, LISTAGG is better.
This does not assume that you are getting the output only for a single intid at a time. You can get any number of them in a suingle query. Of course, that number can be 1 if that's what you want.
Edited by: Frank Kulash on Mar 24, 2011 12:19 PM -
Need help in refining the query
Hello Experts,
Need your help in refining the query further more.
table structure
Mskey Col A Col B
1 empno [20141127-20151128]1234
1 empno [20151201-99991231]232544
1 salutation [20141127-99991231]Mrs
1 salutation [20151127-99991231]Mr
2 empno [20141127-20151128]1234
2 empno [20151201-99991231]232544
2 salutation [20141127-99991231]Mrs
2 salutation [20151127-99991231]Mr
My requirement is to find the list of overlapping records based on the dates
user details may be varying from time to time as new data would be pushed through HR systems to identity store via an interface.
The job is getting failed whenever there is any overlapping with dates. So we proactively decided to schedule a job in this regards which runs weekly and would let us know for which and all the users there is overlapping dates are there, so that we can send the list to HR team for pushing new data.
Overlapping Issue Example:
The users employee id for an year it is 1234 and later he moved to another department and his employee id got changed and it became 2345 remaining all details are same. So the HR systems send the data for this user as empno - [20141127-20151128]1234 and empno - [20151201-99991231]232544
it means from 20141127 to 20151128 his employee no is 1234 and from 20151201 to 99991231 his employee would be 2345.
This is a correct case and the tool would accept this data.
the below cases are invald
Case 1: 1 salutation [20141127-99991231]Mrs 1 salutation [20151127-99991231]Mr
Case 2: 2 salutation [20141127-99991231]Mrs 2 salutation [20141127-99991231]Mr
So we wanted to find these overlapping records from tables.
My Query:
I am able to successfully write query for the case 2 type but unable to write for case1.
select id,colA
count(left(ColB,CHARINDEX(']',ColB))) as 'Count'
from tblA with (nolock)
where id in (Select distinct id from tblb with (nolock))
group by id, cola,left(ColB,CHARINDEX(']',ColB))
having count(left(ColB,CHARINDEX(']',ColB)))>1Finally got the required answer with the below query
WITH Cte AS
SELECT ID,ColA,ColB,ROW_NUMBER() OVER(ORDER BY (SELECT 1)) AS RN,
CAST(SUBSTRING(ColB,2,CHARINDEX('-',ColB)-2) AS DATE) AS StartDT,
CAST(SUBSTRING(ColB,CHARINDEX('-',ColB)+1,8) AS DATE) AS EndDT FROM TblA
SELECT c1.ID, c1.ColA,c1.ColB
FROM Cte c1 JOIN Cte c2
ON c1.RN != c2.RN
AND c1.ID=c2.ID
AND c1.ColA=c2.ColA
AND (c1.StartDT BETWEEN c2.StartDT AND c2.EndDT OR c2.StartDT BETWEEN c1.StartDT AND c1.EndDT ) -
Need help on one odd query results...
Hi Guys,
I need your help,
Requirement is :- Suppose we have got Below titles in one table :-
HULK
THE INCREDIBLE HULK - 2001 (DO NOT USE)
REVERSE HULK
INCREDIBLE HULK U/A
BRING ME HEAD OF THE HULK
JENNIFER JASON LEIGH, HULK HOGAN
HULK 2
BRIDE OF THE INCREDIBLE HULK
HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
INCREDIBLE HULK #03 (1979/80)
HULK HOGAN'S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
Now the requirement is :-
O/p Should be in below order without have duplicate records
HULK first then
HULK % then
%HULK%.
O/p :-
HULK
HULK 2
HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
HULK HOGAN'S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
THE INCREDIBLE HULK - 2001 (DO NOT USE)
REVERSE HULK
INCREDIBLE HULK U/A
BRING ME HEAD OF THE HULK
JENNIFER JASON LEIGH, HULK HOGAN
BRIDE OF THE INCREDIBLE HULK
INCREDIBLE HULK #03 (1979/80)
How can we do it using sql query ? Is it possible to do it one query?
Or need to use PL/SQL table etc?
There should be no duplicate if we use more than one query or single query ..
Can you help?tappusingh wrote:
O/p Should be in below order without have duplicate records
HULK first then
HULK % then
%HULK%. Maybe something like:
SQL> WITH test_tab
2 AS (SELECT 'HULK' col FROM DUAL
3 UNION ALL
4 SELECT 'THE INCREDIBLE HULK - 2001 (DO NOT USE)' FROM DUAL
5 UNION ALL
6 SELECT 'REVERSE HULK' FROM DUAL
7 UNION ALL
8 SELECT 'INCREDIBLE HULK U/A' FROM DUAL
9 UNION ALL
10 SELECT 'BRING ME HEAD OF THE HULK' FROM DUAL
11 UNION ALL
12 SELECT 'JENNIFER JASON LEIGH, HULK HOGAN' FROM DUAL
13 UNION ALL
14 SELECT 'HULK 2' FROM DUAL
15 UNION ALL
16 SELECT 'BRIDE OF THE INCREDIBLE HULK' FROM DUAL
17 UNION ALL
18 SELECT 'HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD' FROM DUAL
19 UNION ALL
20 SELECT 'INCREDIBLE HULK #03 (1979/80)' FROM DUAL
21 UNION ALL
22 SELECT 'HULK HOGAN''S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)'
23 FROM DUAL)
24 -- " end of test data "
25 SELECT DISTINCT col
26 FROM test_tab
27 ORDER BY CASE
28 WHEN col = 'HULK' THEN 1
29 WHEN col LIKE 'HULK%' THEN 2
30 WHEN col LIKE '%HULK%' THEN 3
31 ELSE 4
32 END, col
33 /
COL
HULK
HULK 2
HULK HOGAN'S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
BRIDE OF THE INCREDIBLE HULK
BRING ME HEAD OF THE HULK
INCREDIBLE HULK #03 (1979/80)
INCREDIBLE HULK U/A
JENNIFER JASON LEIGH, HULK HOGAN
REVERSE HULK
THE INCREDIBLE HULK - 2001 (DO NOT USE)
11 rows selected.
SQL>Regards,
Jo -
Hi team,
Please help me on below query,
I have table like given below
Tran_Id tran_date amount. Actorid
1. 10-apr-15. 100. 1
2. 11-apr-15. 100. 1
3. 11-apr-15. 900. 1
4. 12-apr-15. 100. 1
5. 13-apr-15. 350. 1
6. 14-apr-15. 400. 1
Now please find the query,
I want all the actor ids whos tran amount
>1500 and the date when the tran amount
Has breached
Ex:
Actor-id. Breached-date. Total
1. 13-apr-15. 1900
How can I write a query for above requirement?
Regards,
RajendraYour solution (same as Saubhik's) is incorrect. Look at source data - multiple transactions can occur same day. Therefore, your qury will return wrong results if breached amount is 1000:
with trans as (
select 1 tran_Id, to_date('10-apr-15', 'dd-mon-yy') tran_date, 100 amount, 1 actorid from dual union all
select 2, to_date('11-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 3, to_date('11-apr-15', 'dd-mon-yy'), 900, 1 from dual union all
select 4, to_date('12-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 5, to_date('13-apr-15', 'dd-mon-yy'), 350, 1 from dual union all
select 6, to_date('14-apr-15', 'dd-mon-yy'), 400, 1 from dual union all
select 7, to_date('12-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 8, to_date('13-apr-15', 'dd-mon-yy'), 1200, 2 from dual union all
select 9, to_date('14-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 10, to_date('15-apr-15', 'dd-mon-yy'), 300, 2 from dual
trans_running_tot as (
select tran_id, tran_date,
sum(amount) over (partition by actorid order by tran_date) tot_amt, actorid
from trans
trans_ranked as (
select actorid,tran_id, tran_date,
rank() over (partition by actorid order by tot_amt) rk
from trans_running_tot
where tot_amt > 1000
select * from trans_ranked where rk=1
ACTORID TRAN_ID TRAN_DATE RK
1 2 11-APR-15 1 -- here total amount was only 200
1 3 11-APR-15 1
2 8 13-APR-15 1
SQL>
As you can see, 2 rows were returned for actor 1. Why? Default for analytic ORDER BY is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. Therefore, all rows with same transation_date will fall into same window:
SQL> with trans as (
2 select 1 tran_Id, to_date('10-apr-15', 'dd-mon-yy') tran_date, 100 amount, 1 actorid from dual union all
3 select 2, to_date('11-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
4 select 3, to_date('11-apr-15', 'dd-mon-yy'), 900, 1 from dual union all
5 select 4, to_date('12-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
6 select 5, to_date('13-apr-15', 'dd-mon-yy'), 350, 1 from dual union all
7 select 6, to_date('14-apr-15', 'dd-mon-yy'), 400, 1 from dual union all
8 select 7, to_date('12-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
9 select 8, to_date('13-apr-15', 'dd-mon-yy'), 1200, 2 from dual union all
10 select 9, to_date('14-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
11 select 10, to_date('15-apr-15', 'dd-mon-yy'), 300, 2 from dual
12 )
13 select tran_id, tran_date,
14 sum(amount) over (partition by actorid order by tran_date) tot_amt, actorid
15 from trans
16 /
TRAN_ID TRAN_DATE TOT_AMT ACTORID
1 10-APR-15 100 1
2 11-APR-15 1100 1
3 11-APR-15 1100 1
4 12-APR-15 1200 1
5 13-APR-15 1550 1
6 14-APR-15 1950 1
7 12-APR-15 300 2
8 13-APR-15 1500 2
9 14-APR-15 1800 2
10 15-APR-15 2100 2
10 rows selected.
SQL>
So correct solution is to ORDER BY transation id. Also, just in case if amount can be 0, we should add tranaction id when ordering by sum:
with trans as (
select 1 tran_Id, to_date('10-apr-15', 'dd-mon-yy') tran_date, 100 amount, 1 actorid from dual union all
select 2, to_date('11-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 3, to_date('11-apr-15', 'dd-mon-yy'), 900, 1 from dual union all
select 4, to_date('12-apr-15', 'dd-mon-yy'), 100, 1 from dual union all
select 5, to_date('13-apr-15', 'dd-mon-yy'), 350, 1 from dual union all
select 6, to_date('14-apr-15', 'dd-mon-yy'), 400, 1 from dual union all
select 7, to_date('12-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 8, to_date('13-apr-15', 'dd-mon-yy'), 1200, 2 from dual union all
select 9, to_date('14-apr-15', 'dd-mon-yy'), 300, 2 from dual union all
select 10, to_date('15-apr-15', 'dd-mon-yy'), 300, 2 from dual
trans_running_tot as (
select tran_id, tran_date,
sum(amount) over (partition by actorid order by tran_id) tot_amt, actorid
from trans
trans_ranked as (
select actorid,tran_id, tran_date,
rank() over (partition by actorid order by tot_amt,tran_id) rk
from trans_running_tot
where tot_amt > 1000
select * from trans_ranked where rk=1
ACTORID TRAN_ID TRAN_DATE RK
1 3 11-APR-15 1
2 8 13-APR-15 1
SQL>
SY. -
How to determine what Index is required by a query ?
Hi all,
In our application, we create some complex View with complex query.
The question is : How to determine what Index is required by the query ?
I try using SQL Tuning Advisor, but it seems I can only use it After running TOP SQL.
Is there aniway to determine the Index even Before the query under heavy load/ top sql ?
Thank you very much,
xtantoYou can run your explain plan to check the table access path. You can create an index and see if the optimizer is using the index. Then compare the costs. Creating index will help only in some occassion and you need to provide complete details of the requirement to come to a conclusion of which type of INDEX as well. In some occassions, B*Tree index is useful, in few DW applications, bitmap will work efficiently with columns of low cardinality.
So it is again the task for you to look into this.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/toc.htm
Cheers
Sarma. -
XSLT mapping Help Required.
XSLT mapping Help Required.
Hi Experts,
I am New to XSLT Mapping. I am practising the below Example:
InputXML File:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
<ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
<Person>
<FirstName>Anshul</FirstName>
<LastName>Chowdhary</LastName>
<Gender>Male</Gender>
<Address>
<Street>2nd Main</Street>
<Houseno>83/b</Houseno>
<City>Mysore</City>
</Address> </Person>
</ns0:MT_XSLT_Source>
XSL StyleSheet File:
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/Gen"
Xmlns:ns1=”http://XYZ.com/Test”>
<xsl:template match="/">
<ns1:MT_XSLT_Target>
<Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title>
<Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/>
</Name>
<Street> <xsl:value-of select="concat(concat(ns0:Mt_XSLT_Source/Person/Address/Houseno,' '),
ns0:Mt_XSLT_Source/Person/Address/Street)"/> </Street>
<City> <xsl:value-of select="ns0:Mt_XSLT_Source/Person/Address/City"/> </City>
</ns1:MT_XSLT_Target>
</xsl:template>
</xsl:stylesheet>
The Desired Output shuold be:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MT_XSLT_Target xmlns:ns1="http://XYZ.com/Test">
<Title>Male</Title>
<Name>Anshul Chowdhary</Name>
<Street>83/b 2nd Main</Street>
<City>Mysore</City>
</ns1:MT_XSLT_Target>
I have refered the xsl in xml and i am getting the below Oupt in a Single line like this:
Anshul Chowdhary Male 2nd Main 83/b Mysore
I am Unable to display in Target XML Fomrat as shown above. Please check and do the needful.
Regards,
GIRIDHARHi,
I have used below for testing.
Input xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
<ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
<Person>
<FirstName>Anshul</FirstName>
<LastName>Chowdhary</LastName>
<Gender>Male</Gender>
<Address>
<Street>2nd Main</Street>
<Houseno>83/b</Houseno>
<City>Mysore</City>
</Address> </Person>
</ns0:MT_XSLT_Source>
xsl code:
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/gen"
xmlns:ns1="http://XYZ.com/Test">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<ns1:MT_XSLT_Target>
<Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title>
<Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/>
</Name>
<Street> <xsl:value-of select="concat(concat(/ns0:MT_XSLT_Source/Person/Address/Houseno,' '),
/ns0:MT_XSLT_Source/Person/Address/Street)"/> </Street>
<City> <xsl:value-of select="/ns0:MT_XSLT_Source/Person/Address/City"/> </City>
</ns1:MT_XSLT_Target>
</xsl:template>
</xsl:stylesheet>
For testing in PI ,change the extension from .txt to .xsl and zip it and upload into PI as an imported archive .
Regards
Venkat -
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
Hi,
I'm using below query in procedure.It's taking more more time can some one help to tune this query or advice to rewrite the query.
Databse :10.1
SELECT 'Reading Comprehension' TEST_NAME,T.TEST_END_DATE TEST_SESSION_DATE,
C.POOL_VERSION_ID, I.CREATED_ON POOL_CREATED_DT,
C.ITEM_ID, C.ITEM_RESPONSE_ID, S.STUDENT_ID_PK, C.RESPONSE_KEY, C.IS_CORRECT RESPONSE_IS_CORRECT,
T.SCORE SCALE_SCORE, C.RESPONSE_DURATION, P.ITEM_KEY,
T.TEST_SESSION_DETAIL_ID, SYSDATE CREATED_ON
-- BULK COLLECT INTO TV_PSYCHO_DET
FROM
CAT_ITEM_PARAMETER P, CAT_ITEM_USER_RESPONSE C, TEST_SESSION_DETAIL T,
TEST_SESSION S, ITEM_POOL_VERSION I, TEST_DETAIL D
,INSTITUTION E
WHERE TRUNC(T.TEST_END_DATE) BETWEEN TO_DATE('01-11-09','dd-mm-yy') AND TO_DATE('30-11-09','dd-mm-yy')
AND D.TEST_NAME = 'Reading Comprehension'
AND T.TEST_SESSION_STATUS_ID = 3
AND I.POOL_AVAILABILITY='Y'
AND P.PRETEST=0 AND C.RESTART_FLAG=0
AND T.TEST_DETAIL_ID = D.TEST_DETAIL_ID
AND S.TEST_SESSION_ID = T.TEST_SESSION_ID
AND C.TEST_SESSION_DETAIL_ID = T.TEST_SESSION_DETAIL_ID
AND S.INSTITUTION_ID=E.INSTITUTION_ID
AND SUBSTR(E.INSTITUTION_ID_DISPLAY,8,3) <> '000'
AND I.ITEM_ID = C.ITEM_ID
AND P.ITEM_ID = I.ITEM_ID;expln plan
Plan hash value: 3712814491
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart|
Pstop |
| 0 | SELECT STATEMENT | | 50857 | 7151K| 93382 (1)| 00:18:41 | |
|
|* 1 | FILTER | | | | | | |
|
|* 2 | HASH JOIN | | 50857 | 7151K| 93382 (1)| 00:18:41 | |
|
| 3 | PARTITION HASH ALL | | 2312 | 23120 | 25 (0)| 00:00:01 | 1 |
5 |
|* 4 | TABLE ACCESS FULL | CAT_ITEM_PARAMETER | 2312 | 23120 | 25 (0)| 00:00:01 | 1 |
5 |
|* 5 | HASH JOIN | | 94938 | 12M| 93356 (1)| 00:18:41 | |
|
|* 6 | TABLE ACCESS FULL | ITEM_POOL_VERSION | 9036 | 132K| 30 (0)| 00:00:01 | |
|
|* 7 | TABLE ACCESS BY GLOBAL INDEX ROWID | CAT_ITEM_USER_RESPONSE | 9 | 279 | 18 (0)| 00:00:01 | ROWID |
ROWID |
| 8 | NESTED LOOPS | | 45349 | 5270K| 93325 (1)| 00:18:40 | |
|
|* 9 | HASH JOIN | | 4923 | 423K| 11377 (1)| 00:02:17 | |
|
|* 10 | INDEX FAST FULL SCAN | INSTI_ID_NAME_COUN_DISP_IDX | 8165 | 111K| 18 (0)| 00:00:01 | |
|
|* 11 | HASH JOIN | | 4923 | 355K| 11359 (1)| 00:02:17 | |
|
|* 12 | TABLE ACCESS BY GLOBAL INDEX ROWID| TEST_SESSION_DETAIL | 4107 | 148K| 6804 (1)| 00:01:22 | ROWID |
ROWID |
| 13 | NESTED LOOPS | | 4923 | 278K| 6806 (1)| 00:01:22 | |
|
|* 14 | INDEX RANGE SCAN | TEST_DETAIL_AK_1 | 1 | 21 | 2 (0)| 00:00:01 | |
|
|* 15 | INDEX RANGE SCAN | TEST_SESSION_DETAIL_FK2_I | 39737 | | 102 (0)| 00:00:02 | |
|
| 16 | PARTITION HASH ALL | | 1672K| 25M| 4546 (1)| 00:00:55 | 1 |
5 |
| 17 | TABLE ACCESS FULL | TEST_SESSION | 1672K| 25M| 4546 (1)| 00:00:55 | 1 |
5 |
|* 18 | INDEX RANGE SCAN | CAT_ITEM_USER_RESP_IDX1 | 18 | | 3 (0)| 00:00:01 | |
|
Predicate Information (identified by operation id):
1 - filter(TO_DATE('01-11-09','dd-mm-yy')<=TO_DATE('30-11-09','dd-mm-yy'))
2 - access("P"."ITEM_ID"="I"."ITEM_ID")
4 - filter("P"."PRETEST"=0)
5 - access("I"."ITEM_ID"="C"."ITEM_ID")
6 - filter("I"."POOL_AVAILABILITY"='Y')
7 - filter(TO_NUMBER("C"."RESTART_FLAG")=0)
9 - access("S"."INSTITUTION_ID"="E"."INSTITUTION_ID")
10 - filter(SUBSTR("E"."INSTITUTION_ID_DISPLAY",8,3)<>'000')
11 - access("S"."TEST_SESSION_ID"="T"."TEST_SESSION_ID")
12 - filter(TRUNC(INTERNAL_FUNCTION("T"."TEST_END_DATE"))>=TO_DATE('01-11-09','dd-mm-yy') AND "T"."TEST_SESSION_STATUS_ID"=3
AND TRUNC(INTERNAL_FUNCTION("T"."TEST_END_DATE"))<=TO_DATE('30-11-09','dd-mm-yy'))
14 - access("D"."TEST_NAME"='Reading Comprehension')
15 - access("T"."TEST_DETAIL_ID"="D"."TEST_DETAIL_ID")
18 - access("C"."TEST_SESSION_DETAIL_ID"="T"."TEST_SESSION_DETAIL_ID")
43 rows selected.Edited by: user575115 on Dec 18, 2009 12:31 AMWhen you see something like ...
7 - filter(TO_NUMBER("C"."RESTART_FLAG")=0) It means that Oracle had to do a conversion for you since you aren't using the proper data type in your query.
That would mean IF there is an index on that column, it won't be useable...
Maybe you are looking for
-
Out standing MIS Report query problem.
Hi, We designed MIS Report for outstanding mis through Crystal report.here we are facing probleme.ex:AR invoice raised on 01 Jan 09 bill amount 1000 and for this client is received full amount against that bill on 04 march09.in this report we provide
-
I have read through several responses to others who are having problems following an update. I am not computer savvy enough to understand half of the recommended 'solutions'. I need clear and definitive instructions of what to do. (Instruction for 'd
-
I am unable to instal itunes (greater than version 7) as it gives me the error,"Bonjour service failed to start, verify you have sufficient privileges" , i have checked on apple support and the only help for this error says that mcafee antivirus is b
-
ITunes 8: When downloading album artwork for making thumbnails, it quits?
I just installed iTunes 8, and I tried opening it. It then starts to download the album artwork thumbnails, then all of a sudden a message shows saying, "iTunes has stopped working, Windows is trying to blablabla.." Then it forces you to closes the p
-
FI Archive questions for object FI_DOCUMNT
I am on a team that is currently implementing an Archiving strategy for financial data through the FI_DOCUMNT archiving object and we have a few questions: 1. Is it possible to perform the revaluation process on an account (for example the Cash accou