Logic needed by the query
Hi allI have a table with columns
LUN MAR SEA GAME FRI SAT SUN
-----------------------------------------------------------
Y................ ........ Y..................
I need selected the SUN column, which is Sunday.
Along with this, I need to select columns, Tue
THU a value so I do not need that
If I select the SEA then I needed game, sat, Sam also
pls can u help on this.
Published by: 881121 on April 5, 2013 23:13
This seems the most populous wire, only the moderator suggested to stick. Related: {: identifier of the thread = 2522286}
with
the_table as
(select id_,sun,mon,tue,wed,thu,fri,sat
from (select 1 id_,'Y' sun,'N' mon,'N' tue,'Y' wed,'N' thu,'N' fri,'N' sat from dual union all
select 2 id_,'N' sun,'Y' mon,'N' tue,'Y' wed,'N' thu,'N' fri,'N' sat from dual union all
select 3 id_,'N' sun,'N' mon,'N' tue,'N' wed,'N' thu,'Y' fri,'N' sat from dual union all
select 4 id_,'N' sun,'N' mon,'Y' tue,'Y' wed,'N' thu,'N' fri,'Y' sat from dual
)
)
select id_,the_day,dow,
nvl(lead(dow,1) over (partition by id_ order by dow),
first_value(dow) over (partition by id_ order by dow)
) next_dow
from (select id_,the_day,day_value,dow
from (select id_,'sun' the_day,sun day_value,1 dow from the_table union all
select id_,'mon' the_day,mon day_value,2 dow from the_table union all
select id_,'tue' the_day,tue day_value,3 dow from the_table union all
select id_,'wed' the_day,wed day_value,4 dow from the_table union all
select id_,'thu' the_day,thu day_value,5 dow from the_table union all
select id_,'fri' the_day,fri day_value,6 dow from the_table union all
select id_,'sat' the_day,sat day_value,7 dow from the_table
)
start with day_value = 'Y'
connect by dow = prior case when dow + 1 > 7 then dow - 6 else dow + 1 end
and id_ = prior id_
and day_value = 'N'
and level <= 7
)
where day_value = 'Y'
order by id_,dow
Concerning
Etbin
Tags: Database
Similar Questions
-
Logic needed for the increment value
Hello
This function returns me if I pass "ABC01" it returns "ABC02" as if I spend
"ABC55" it returns "ABC56".
But my requirment is that I need to pass the value from 01 to 99.
so, if I'm going 'ABC99' it back South "ABC01'.
If the sequence is from 01 to 99 and after 99 he will still leave the 01.
create or replace function get_next_value
(
string_1 in varchar2
)
return varchar2
as
v_string_1 number (10);
v_string_2 varchar2 (10);
Start
Select to_number (substr(string_1,4)) + 1 in double v_string_1;
If length (v_string_1) = 1 then
v_string_2: = substr (string_1, 1, 4). v_string_1;
Return v_string_2;
on the other
v_string_2: = substr (string_1, 1, 3). v_string_1;
Return v_string_2;
end if;
end;
******************************************
test sript
Select get_next_value ('ABC01') of double
Select get_next_value ('ABC55') of double
Thank you
Lony
-
Logical operators in the query select Oracle
Hi all
Can I use the logical operators in queries select oracle?
for 1 and 0 = 0; 1 or 0 = 0
If I have a 1010 value two fields in a table COL1 and COL2 have a value of 0001.
Is it possible to use select col1 or col2 from table? where or is a logical operator.
Kind regardsselect bitand(6,8) from dual; BITAND(6,8) -------- 0
-
Need for the sql query to have several columns in a single coulumn
Hi all
I need create the query to have several columns in a single column with several lines.
Select a.customer_trx_id, a.previous_customer_trx_id
of ra_customer_trx_all one
where a.customer_trx_id =: customer_trx_id
Here, a.customer_trx_id and a.previous_customer_trx_id are in two columns. I need to put them in a single column.
Say: the foregoing is output
--------------------------------------------------------------------------------
a.customer_trx_id a.previous_customer_trx_id
--------------------------------------------------------------------------------
123456 87654
--------------------------------------------------------------------------------
Need for a single column
As
--------------------------------------------------------------------------------
123456
87654
--------------------------------------------------------------------------------
Please do the needful. Please note that it is not the UNION.
Thank you
AbdulHello
You want a way to confirm that what looks like two rows is really a line?
Here are three ways:
(1) count the lines:
WITH my_original_querry AS ( select a.customer_trx_id || CHR(13) || a.previous_customer_trx_id as id from ra_customer_trx_all a where a.customer_trx_id = 274881 ) SELECT COUNT (*) FROM my_original_query;
(2) in SQL * Plus, have SQL * more count them for you:
SET FEEDBACK 1 select a.customer_trx_id || CHR(13) || a.previous_customer_trx_id as id from ra_customer_trx_all a where a.customer_trx_id = 274881;
(3) implicitly count them with the ROWNUM Pseudo-column
select a.customer_trx_id || CHR(13) || a.previous_customer_trx_id as id , ROWNUM from ra_customer_trx_all a where a.customer_trx_id = 274881;
-
Hello
Kindly let me know how to print the query, and the parameters passed to it? I tried with the params parameter in super.executeQueryForCollection (qc, params, noUserParams); but could not succeed.
I need save the query and the parameters passed to it. Kindly help.
Thanks in advance,
Kalpana.
Here you go
Coding with Passion: Oracle ADF - Debug Mode object query with parameters
-
Not able to understand the query logic
Hello
Please, help me to understand the logic of the query below.
I have an emp table having 2 emp_id and mgr_id column.
data from table.
emp_id mgr_id
1
2 2
3 3
4 5
5
6 5
6 of 7
6 of 8
9 7
I run the query below...
Select * from emp where emp_id not in (select mgr_id from emp);
Query giving no line.
I need to know the logic of the query.
Thank you
HIMSBecause there are some NULL values in the column so 'IN' mgr_id would fail to compare values such as 1,4,8,9 which are not there in mgr_id with these NULL values.
Use NVL like below to get the desired results...
with t as ( select 1 emp_id, null mgr_id from dual union all select 2,2 from dual union all select 3,3 from dual union all select 4,5 from dual union all select 5,null from dual union all select 6,5 from dual union all select 7,6 from dual union all select 8,6 from dual union all select 9,7 from dual ) SELECT * FROM t WHERE emp_id NOT IN (SELECT nvl(mgr_id,0) from t );
Concerning
Arun -
I need to stop a download of the query, that I thought a stand-alone application but turns require a higher level (FCPX) as a 'parent' and I do not have that, or I want to buy it.
Motion IS a stand-alone application. It is mainly designed to make effects for Final Cut Pro X, but it is not necessary to have with FCPX nor is it necessary to have FCPX to create projects for other purposes. When you open the query, simply select project of work outside the FCPX motion. You can save regular projects of Motion anywhere on your system.
-
Need help to understand the query result
Hi gurus
I was reading one of the question here in this forum and its link is below:
I had some confusion related to this code and don't understand the logic of the out put, see query below:
Query
with sub_services as
(
Select su_seq 12323, 'HLR1' so_id, 1 seq Union double all the
Select su_seq 12323, "HLR2' so_id, seq 2 Union double all the
Select su_seq 12323, "A09" so_id, seq 3 of all the double union
Select su_seq 12333, "MO1" so_id, seq 4 Union double all the
Select su_seq 12333, "MO2' so_id, seq 5 Union double all the
Select su_seq 12333, "A09" so_id, 6 seq in union double all the
Select su_seq 12333, 'M0CR' so_id, seq 7 Union double all the
Select su_seq 12999, "LOL1' so_id, seq 8 Union double all the
Select su_seq 12999, "LOL2' so_id, seq 9 double
)
Select *.
of sub_services b
where exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
)
order by 2;
The query result
12323 A09 3
12333 6 A09
12323 HLR1 1
12323 HLR2 2
12333 M0CR 7
12333 4 MO1
12333 5 MO2
According to my understanding, the above query should return records in red only because of her is below command
It exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
but don't know why he's back 7 files, can someone help me understand the result...
It is query is functionally identical to the PL/SQL block, but much more effective.
declare
number of l_res;
Start
for line (select *)
sub_services) loop
Start
Select 1 from l_res
of sub_services
where su_seq = row.su_seq and
so_id = "A09" and
rownum = 1;
Essentially every row in the outer query are tested against him exists query. Given the correlation between two requests is based only on su_seq each line with a su_seq value returned by him is returned in the output.
Another way to think he uses instead a join condition. This query is equivalent to the query to exist
Select the main
of main sub_services
Join select (separate su_seq
of sub_services
where so_id = "A09") cond
We main.su_seq = cond.su_seq;
John
-
Need help with the query to get the County
Hello
Oracle 10 g 2 10.2.0.3 - 64 bit
I want back the number of accounts with two different types of funds (say A and B). Some accounts hold only one of the two funds, and some support both. I want to get the counts like this:
- account held funds - has only
- accounts holding funds-B only
- accounts holding the Fund-A and B funds
Here is what I started with but need assistance to meet the requirement above:
select count(distinct acct.bkoff_acct_no ) accounts_holding_fund_A from xe_account acct, xec_tal_investment_mandate iman, xec_tal_asset_allocation alloc, xe_benchmark bmark, xe_benchmark_usage bu, xe_object_description xod, xec_asset_class cls where iman.mandate_status_cd='A' and cls.asset_class_cd = alloc.asset_class_cd and iman.mandate_id = alloc.mandate_id and acct.account_id = iman.object_id and iman.object_type_cd = 'ACCT' and iman.mandate_id = xod.object_id and xod.field_nm='XEC_TAL_INVESTMENT_MANDATE.COMMENT_TXT' and xod.language_cd = 'E' and acct.acct_status_cd = 'O' and bu.object_type_cd(+) = 'TMAA' and bu.object_id(+) = alloc.asset_allocation_id and bmark.benchmark_id(+) = bu.benchmark_id and alloc.resp_txt like '%fund-A%'
And suppose that the Fund-B has resp_txt like ' % of Fund-B»
Please suggest.
Concerning
Hello
Here is another way, it is easier to adapt to different jobs and different numbers of jobs:
WITH got_distinct_jobs AS
(
SELECT DISTINCT deptno, job
FROM scott.emp
WHERE job IN ("ANALYST", "CLERKS") - or what
)
got_job_list AS
(
SELECT LISTAGG (job, ",") THE Group (ORDER BY work) AS job_list
OF got_distinct_jobs
GROUP BY deptno
)
SELECT job_list
COUNT (*) AS num_departments
OF got_job_list
GROUP BY job_list
;
This shows all the combinations of the jobs listed in the WHERE clause of got_distinct_jobs. You don't need to change anything else in the query. There may be any number of jobs.
Output:
JOB_LIST NUM_DEPARTMENTS
------------------------------ ---------------
CLERK 2
ANALYST, CLERK 1
-
Hi all
I have the below where all the WITH clause needs to separate query and SELECT article queries must be separated. Any help is very appreciated. Try SUBSTR and INSTR.
SQL query:
######################################################################
WITH
test_does1 like)
Select 'Y' in double
)
Select *.
of test_does1
UNION ALL
SELECT 'X' FROM double
UNION ALL
SELECT 'A' FROM dual
UNION ALL
WITH
test_does2 like)
Select 'Y' in double
)
Select *.
of test_does2
######################################################################
OK... Then try the below (LISTAGG will not work in oracle 10g)
-Separate with clause
SELECT DBMS_XMLGEN. CONVERT (RTRIM (XMLAGG (XMLELEMENT (E, str |)))) "UNION ALL"). " (Extract ('//Text ()')), 'UNION ALL'), 1) lsval
FROM (SELECT LEVEL, LTRIM (REPLACE (REGEXP_SUBSTR(str1,'[^,]+',1,LEVEL), CHR (10))) str)
FROM (SELECT REPLACE (' WITH test_does1 AS))
(SELECT "Y" FROM dual)
)
SELECT * from test_does1
UNION ALL
SELECT "X" FROM dual
UNION ALL
SELECT "A" dual FROM
UNION ALL
WITH test_does2 AS
(SELECT "Y" FROM dual)
)
SELECT * FROM test_does2 ',' UNION ALL ',',') str1
THE DOUBLE)
CONNECT BY LEVEL<= length(regexp_replace(str1,="" '[^,]+'))="">=>
WHERE the str AS "WITH % ';
-Select to separate
SELECT DBMS_XMLGEN. CONVERT (RTRIM (XMLAGG (XMLELEMENT (E, str |)))) "UNION ALL"). " (Extract ('//Text ()')), 'UNION ALL'), 1) lsval
FROM (SELECT LEVEL, LTRIM (REPLACE (REGEXP_SUBSTR(str1,'[^,]+',1,LEVEL), CHR (10))) str)
FROM (SELECT REPLACE (' WITH test_does1 AS))
(SELECT "Y" FROM dual)
)
SELECT * from test_does1
UNION ALL
SELECT "X" FROM dual
UNION ALL
SELECT "A" dual FROM
UNION ALL
WITH test_does2 AS
(SELECT "Y" FROM dual)
)
SELECT * FROM test_does2 ',' UNION ALL ',',') str1
THE DOUBLE)
CONNECT BY LEVEL<= length(regexp_replace(str1,="" '[^,]+'))="">=>
WHERE str AS 'CHOOSE % ';
-Unit tests
SQL > SELECT DBMS_XMLGEN. CONVERT (RTRIM (XMLAGG (XMLELEMENT (E, str |)))) "UNION ALL"). " (Extract ('//Text ()')), 'UNION ALL'), 1) lsval
2 FROM (SELECT LEVEL, LTRIM (REPLACE (REGEXP_SUBSTR(str1,'[^,]+',1,LEVEL), CHR (10))) str)
3 (SELECT REPLACE (' WITH test_does1 AS))
4 (SELECT "Y" FROM dual)
5 )
6. SELECT * FROM test_does1
7 UNION ALL
8 "X" SELECT FROM dual
9 UNION ALL
10. SELECT "A" dual FROM
11 UNION ALL
12 test_does2 WITH AS
13 (SELECT "Y" FROM dual)
14)
15 SELECT * FROM test_does2 ',' UNION ALL ',',') str1
16 DOUBLE)
17 CONNECT BY LEVEL<= length(regexp_replace(str1,="" '[^,]+'))="">=>
18. WHERE LIKE str "WITH % ';
LSVAL
--------------------------------------------------------------------------------
WITH test_does1 AS (SELECT FROM dual 'Y') SELECT * FROM test_does1 UNION ALL
WITH test_does2 AS (SELECT FROM dual 'Y') SELECT * FROM test_does2
SQL > SELECT DBMS_XMLGEN. CONVERT (RTRIM (XMLAGG (XMLELEMENT (E, str |)))) "UNION ALL"). " (Extract ('//Text ()')), 'UNION ALL'), 1) lsval
2 FROM (SELECT LEVEL, LTRIM (REPLACE (REGEXP_SUBSTR(str1,'[^,]+',1,LEVEL), CHR (10))) str)
3 (SELECT REPLACE (' WITH test_does1 AS))
4 (SELECT "Y" FROM dual)
5 )
6. SELECT * FROM test_does1
7 UNION ALL
8 "X" SELECT FROM dual
9 UNION ALL
10. SELECT "A" dual FROM
11 UNION ALL
12 test_does2 WITH AS
13 (SELECT "Y" FROM dual)
14)
15 SELECT * FROM test_does2 ',' UNION ALL ',',') str1
16 DOUBLE)
17 CONNECT BY LEVEL<= length(regexp_replace(str1,="" '[^,]+'))="">=>
18. WHERE str LIKE "SELECT % ';
LSVAL
--------------------------------------------------------------------------------
SELECT 'X' FROM dual UNION ALL SELECT 'A' double
-
Need help with the query. Help, please
Hey everyone, need your help. Thank you in advance. In my view, there is function Pivot. Just do not know how to use this function. I have the query that works. The result is:
11-111-1111 Vlad 16505 01/04/2013 5 August 13 dental plan pre-tax amount 29,65
11-111-1111 Vlad 16505 01/04/2013 dental pre-tax 5 August 13 Plan level EE + SP
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Option TOP dental plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax dental care plan pay the value
11-111-1111 16505 Vlad 01/04/2013 dental pre-tax 5 August 13 Plan period Type
11-111-1111 Vlad 16505 01/04/2013 amount pre-tax medical Plan of 5 August 13 149
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Medical Plan level EE + SP
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan medical Option MED
11-111-1111 Vlad 16505 01/04/2013 5 August 13 plan pre-tax pay value
11-111-1111 16505 Vlad 01/04/2013 5 August 13 pre-tax Medical Plan period Type
11-111-1111 Vlad 16505 01/04/2013 5 August 13 pre-tax Plan PPO medical Plan
11-111-1111 Vlad 16505 01/04/2013 5 August 13 Vision Plan amount 5.94 pre-tax
But I need the result to be
Amount of SSN ID name item level Option PayValue period Type
11-111-1111 Vlad 16505 01/04/2013 null null high of 5 August 13 pre-tax Dental Plan 29,65 EE + SP
11-111-1111 Vlad 16505 01/04/2013 null null MED 5 August 13 149 medical plan pre-tax EE + SP
11-111-1111 Vlad 16505 01/04/2013 Vision Plan before taxes of 5 August 13
Select distinct
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as EMPLOYEE_FULL_NAME,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as Date_Of_Hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_valueOf
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1'
order of petf.element_name;Change with your query
SELECT * FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
PIVOT (MAX (screen_entry_value) FOR (name) TO ("Amount" AS 'Amount', 'level' AS 'level', 'Option High' AS 'High Option', 'Pay the value' AS 'Value to pay', 'Period of Type' AS 'Type period'))
order by element_name;
(GOLD)
SELECT ssn,
Employee_number,
employee_full_name,
date_of_hire,
effective_start_date,
element_name,
Max (decode (Name, 'Amount', screen_entry_value)) 'amount. "
Max (decode (Name, 'Level', screen_entry_value)) 'level ',.
MAX (DECODE (name, "High Option", screen_entry_value)) "High Option",
MAX (DECODE (name, 'Value of pay', screen_entry_value)) 'value of pay. "
MAX (DECODE (name, 'Period Type', screen_entry_value)) 'period of Type '.
FROM (select distinct)
' 11-111-1111 "as ssn,
WOMEN'S WEAR. Employee_number,
"Vlad" as employee_full_name,
TO_CHAR (papf.start_date, "MM/DD/YYYY") as date_of_hire
a.effective_start_date,
PETF.element_name,
pivf. Name,
peevf.screen_entry_value
Of
PER_all_PEOPLE_F women's wear
per_assignments_f A
pay_element_types_f petf
pay_element_links_f pelf
PAY_ELEMENT_ENTRIES_F penf
PAY_ELEMENT_ENTRY_VALUES_F peevf
pay_input_values_f pivf
WHERE
PETF.element_name ('Dental Plan before taxes', 'Medical Plan before taxes', "Vision Plan before taxes")
and petf. ELEMENT_TYPE_ID = pelf. ELEMENT_TYPE_ID
and (trunc (sysdate) BETWEEN pelf. EFFECTIVE_START_DATE AND pelf. EFFECTIVE_END_DATE)
and (pelf. ELEMENT_LINK_ID = penf. ELEMENT_LINK_ID and a.assignment_id = penf. ASSIGNMENT_ID)
and (trunc (sysdate) BETWEEN penf. EFFECTIVE_START_DATE AND penf. EFFECTIVE_END_DATE)
and penf. ELEMENT_ENTRY_ID = peevf. ELEMENT_ENTRY_ID
and peevf. INPUT_VALUE_ID = pivf. INPUT_VALUE_ID
AND papf.employee_number IS NOT NULL
AND A.assignment_type = 'E '.
AND A.person_id = papf.person_id
and papf.effective_end_date > sysdate
and a.effective_end_date > sysdate
and (trunc (sysdate) BETWEEN women's wear. EFFECTIVE_START_DATE AND women's wear. EFFECTIVE_END_DATE)
and a.effective_start_date = (select MAX (effective_start_date) from PER_ASSIGNMENTS_f where assignment_id = a.assignment_id)
and a.assignment_id = 42643
and a.assignment_status_type_id = '1')
GROUP BY ssn, employee_number, employee_full_name, date_of_hire, effective_start_date, NOM_ELEMENT
order by element_name;
-
need help with the query, thx
Hello
I need a little help with the query I have to write;
the table has 4 columns:
what I am asking is the following result: salary according to the latest available yearcol1 col2 col3 col4 emp_name empl_id salary year content of data: col1 col2 col3 col4 smith 12 1200 1999 smith 12 1340 2000 smith 12 1500 2001 jones 13 1550 1999 jones 13 1600 2000 aron 14 1200 2002
i.e.
ID appreciate some guidance on how to achievesmith 12 1500 2001 jones 13 1600 2000 aron 14 1200 2002
Thank you
Rgdsselect *from (select col1, col2,col3, col4,row_number() over(partition by col1 order by col4 desc) rn from
) where rn=1 -
Need help to highlight the query text in the document
Hi, I'm trying to load files into the blob column and try to create the text index.
I need to query the blob column in the original glass by a string, which should return the relevant documents with the query string, highlighted with some color.
Can you please help me with an example of the above.
Thanks in advance.SCOTT@orcl_11gR2> -- table: SCOTT@orcl_11gR2> CREATE TABLE document_tab 2 (document_col BLOB) 3 / Table created. SCOTT@orcl_11gR2> -- procedure to load documents: SCOTT@orcl_11gR2> CREATE OR REPLACE PROCEDURE load_document 2 (p_dir IN VARCHAR2, 3 p_file IN VARCHAR2) 4 AS 5 v_blob BLOB; 6 v_bfile BFILE; 7 BEGIN 8 INSERT INTO document_tab (document_col) 9 VALUES (EMPTY_BLOB()) 10 RETURNING document_col INTO v_blob; 11 v_bfile := BFILENAME (UPPER (p_dir), p_file); 12 DBMS_LOB.FILEOPEN (v_bfile, DBMS_LOB.LOB_READONLY); 13 DBMS_LOB.LOADFROMFILE (v_blob, v_bfile, DBMS_LOB.GETLENGTH (v_bfile)); 14 DBMS_LOB.FILECLOSE (v_bfile); 15 END load_document; 16 / Procedure created. SCOTT@orcl_11gR2> SHOW ERRORS No errors. SCOTT@orcl_11gR2> -- load documents (directory and files must be on server, not client): SCOTT@orcl_11gR2> CREATE OR REPLACE DIRECTORY my_dir AS 'c:\my_oracle_files' 2 / Directory created. SCOTT@orcl_11gR2> BEGIN 2 load_document ('my_dir', 'banana.pdf'); 3 load_document ('my_dir', 'english.doc'); 4 load_document ('my_dir', 'sample.txt'); 5 END; 6 / PL/SQL procedure successfully completed. SCOTT@orcl_11gR2> -- confirm files were loaded: SCOTT@orcl_11gR2> SELECT DBMS_LOB.GETLENGTH (document_col) 2 FROM document_tab 3 / DBMS_LOB.GETLENGTH(DOCUMENT_COL) -------------------------------- 222824 22016 60 3 rows selected. SCOTT@orcl_11gR2> -- text index: SCOTT@orcl_11gR2> CREATE INDEX document_idx 2 ON document_tab (document_col) 3 INDEXTYPE IS CTXSYS.CONTEXT 4 / Index created. SCOTT@orcl_11gR2> -- confirm files were indexed: SCOTT@orcl_11gR2> SELECT COUNT(*) FROM dr$document_idx$i 2 / COUNT(*) ---------- 319 1 row selected. SCOTT@orcl_11gR2> -- function to return highlighted document: SCOTT@orcl_11gR2> CREATE OR REPLACE FUNCTION your_markup 2 (p_index_name IN VARCHAR2, 3 p_textkey IN VARCHAR2, 4 p_text_query IN VARCHAR2, 5 p_plaintext IN BOOLEAN DEFAULT TRUE, 6 p_tagset IN VARCHAR2 DEFAULT 'HTML_DEFAULT', 7 p_starttag IN VARCHAR2 DEFAULT '*', 8 p_endtag IN VARCHAR2 DEFAULT '*', 9 p_key_type IN VARCHAR2 DEFAULT 'ROWID') 10 RETURN CLOB 11 AS 12 v_clob CLOB; 13 BEGIN 14 CTX_DOC.SET_KEY_TYPE (p_key_type); 15 CTX_DOC.MARKUP 16 (index_name => p_index_name, 17 textkey => p_textkey, 18 text_query => p_text_query, 19 restab => v_clob, 20 plaintext => p_plaintext, 21 tagset => p_tagset, 22 starttag => p_starttag, 23 endtag => p_endtag); 24 RETURN v_clob; 25 END your_markup; 26 / Function created. SCOTT@orcl_11gR2> SHOW ERRORS No errors. SCOTT@orcl_11gR2> -- query that returns highlighted document: SCOTT@orcl_11gR2> VARIABLE string VARCHAR2(100) SCOTT@orcl_11gR2> EXEC :string := 'test AND demonstration' PL/SQL procedure successfully completed. SCOTT@orcl_11gR2> SELECT your_markup ('document_idx', ROWID, :string) 2 AS highlighted_text 3 FROM document_tab 4 WHERE CONTAINS (document_col, :string) > 0 5 /
HIGHLIGHTED_TEXT
--------------------------------------------------------------------------------
It is a document test of demonstration to highlight.1 selected line.
Scott@orcl_11gR2 >
-
Need help in the optimization of the query with the Group and joins by clause
I'm having the problem by running the following query... It takes a lot of time. To simplify, I added the two tables FILE_STATUS = stores the file load details and COMM table Board table job showing records treated successfully and which was communicated to the other system real. Records with status = T is trasnmitted to another system and traansactions with P is waiting.
Here's the query I wrote to give me the details of the file that has been loaded into the system. He reads the table of State and the commission files to display the name of the file, total records loaded, total at the table of the commission and the number of records which has finally been passed successfully loaded (Status = T) with other systems.CREATE TABLE FILE_STATUS (FILE_ID VARCHAR2(14), FILE_NAME VARCHAR2(20), CARR_CD VARCHAR2(5), TOT_REC NUMBER, TOT_SUCC NUMBER); CREATE TABLE COMM (SRC_FILE_ID VARCHAR2(14), REC_ID NUMBER, STATUS CHAR(1)); INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4); INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0); INSERT INTO COMM VALUES ('12345678', 1, 'T'); INSERT INTO COMM VALUES ('12345678', 3, 'T'); INSERT INTO COMM VALUES ('12345678', 4, 'P'); INSERT INTO COMM VALUES ('12345678', 5, 'P'); COMMIT;
In production, this request has several joins and takes a long time to deal with... the main culprit for me is the join on the COMM table to count the number of number of transactions sent. Please can you give me tips to optimize this query to get results faster? What I need to delete the Group and use the partition or something else. Help, please!SELECT FS.CARR_CD ,FS.FILE_NAME ,FS.FILE_ID ,FS.TOT_REC ,FS.TOT_SUCC ,NVL(C.TOT_TRANS, 0) TOT_TRANS FROM FILE_STATUS FS LEFT JOIN ( SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS FROM COMM WHERE STATUS = 'T' GROUP BY SRC_FILE_ID ) C ON C.SRC_FILE_ID = FS.FILE_ID WHERE FILE_ID = '12345678';
Don't know if it will be faster based on the information provided, but analytical functions offer an alternative approach;
select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans from (select fs.carr_cd, fs.file_name, fs.file_id, fs.tot_rec, fs.tot_succ, count(case when c.status = 'T' then 1 else null end) over(partition by c.src_file_id) tot_trans, row_number() over(partition by c.src_file_id order by null) rn from file_status fs left join comm c on c.src_file_id = fs.file_id where file_id = '12345678') where rn = 1; CARR_CD FILE_NAME FILE_ID TOT_REC TOT_SUCC TOT_TRANS ------- -------------------- -------------- ---------- ---------- ---------- LIBM CM_LIBM.TXT 12345678 5 4 2
-
Extend the VO - need to change the query of VO - screen is off
{Re-post the message in this forum (thanks to John Stegeman to lead me here...) {Posted: August 28, 2009 04:27}
Dear all,
Thanks to this great body of knowledge, I ask my questions.
I need to extend a VO to display the name of the country.
The column is not in the VO. So, I need to get another table: FndTerritories
I want to change the query, but the request frame is turned off (in the wizard the View - step 5 of 6 - Generated statement object substitution)
Could you be it someone please let me know: how to change the application of the VO in this case?
OR is there another solution for such cases, to maintain development standards
Thank you very much
Kind regardsHello
I think that's when you just have to add an attribute, you should not click the expert mode checkbox... make use of
Mix and add the button.But when you need to modify the query, and then we want to use to modify the query window...
Thank you
Gerard
Maybe you are looking for
-
Why firefox crashes my pc unexpectedly?
I have a Toshiba laptop to windows 8. I have always used firefox for a year, ever since I got it, it's my choice of web browsers, but today, something has gone wrong. I went to open firefox and it crashed to the point where I couldn't even open the T
-
I need to install the drivers for my printer HP laser jet mfp 1536dnf
I just bought a HP laserJet 1536dnf mfp printer and can't find the drivers, could you help me get it someone please with that? [Moved from comments]
-
Boxes wireless printer work without connection to the modem HP 6700 printer
My printer is located on the second floor of our House. It is connected to our network with the modem and the router to the first floor where my wife's computer. This connection works fine. My problem is that my printer only works if connected to my
-
Original title: driver atikmdag error message when using the full screen. Error message indicating the display driver r300 unresponsive, but has recovered, usually when enter full screen mode.