How to make this query go faster
Hi ,
I have the following query :
select a.* from
tbl1 a , tbl2 b
where a.id = b.id
substr(b.id , 3, 2) <> 'XX'
and b.date1 is not null
and b.date1 >= sysdate - 90 ;
tbl1 - 21 million rows
tbl2 - 2 millions
i specify this hints /*+ INDEX(idxa_1 , idxa_2) INDEX(ixdb_1)
where idxa_1 --> b.lotid
idxa_2 --> b.date1
idxb_1 --> a.lotid
IF i DO NOT include b.date1 is not null and b.date1 >= sysdate - 90 ,
from explain plan i could see it using a FAST FULL SCAN which really returns very fast
HOWEVER if i include b.date1 is not null and b.date1 >= sysdate - 90
, from explain plain it uses row index and then there's a range scan and its slow
how can i improve the performance of this query ?
pls advise
tks & rdgs
Don't create the temporary table.
Create a function based index on table two
substr(id , 3, 2)Make sure you have gathered statistics on the tables.
Remove the hint.
select a.* from
tbl1 a , tbl2 b
where a.id = b.id
and substr(b.id , 3, 2) <> 'XX'
and b.date1 >= sysdate - 90;If you still have performance problems, post the formatted explain plan from sqlplus.
Read the Performance Tuning Guide.
Unfortunately this is not urs advice.
Similar Messages
-
How do make this query ?
CREATE TABLE CLIENT (
CLIENTID NUMBER PRIMARY KEY,
NAME VARCHAR2(40)
CREATE TABLE SALESMAN (
SALESMANID NUMBER PRIMARY KEY,
NAME VARCHAR2(40),
ALL_CLIENTS NUMBER -- ACCESS ALL CLIENTS IF VALUE IS 1
CREATE TABLE CLIENTSALESMAN (
SALESMANID NUMBER,
CLIENTID NUMBER
INSERT INTO CLIENT VALUES(1,'Bob');
INSERT INTO CLIENT VALUES(2,'Jhon');
INSERT INTO CLIENT VALUES(3,'Robert');
INSERT INTO CLIENT VALUES(4,'Clarck');
INSERT INTO SALESMAN VALUES (1,'Christina',0);
INSERT INTO SALESMAN VALUES (2,'Doug',1); -- access all clients
INSERT INTO CLIENTSALESMAN VALUES (1,1);
INSERT INTO CLIENTSALESMAN VALUES (1,2);
How do you return all the clients of a salesman ? same that SALESMAN.ALL = 1 OR SALESMAN.ALL = 0.
the salesman.all is 1 then he access all clients no need insert in CLIENTSALESMAN. If SALESMAN.ALL = 0 he
access clientsalesman.
Does somebody some suggestion how i make this ?
thanks !1 select *
2 from (select a.name SALESMAN, b.name CLIENT
3 from salesman a, client b, clientsalesman
4 where a.SALESMANID = c.SALESMANID
5 and b.CLIENTID = c.CLIENTID
6 union
7 select a.name SALESMAN, b.name CLIENT
8 from salesman a, client b
9 where a.ALL_CLIENTS = 1)
10* where salesman = '&1'
SQL> /
Enter value for 1: Christina
old 10: where salesman = '&1'
new 10: where salesman = 'Christina'
Christina Bob
Christina Jhon
SQL> /
Enter value for 1: Doug
old 10: where salesman = '&1'
new 10: where salesman = 'Doug'
Doug Bob
Doug Clarck
Doug Jhon
Doug RobertNicolas. -
How to make this code go faster?
Hi,
I have this code and its really slow. My question is how to make it faster since its taking about 10 hours.
Code:
loop at ti_equi.
select matnr sernr lief_nr kunde datum uzeit bwart posnr
appending corresponding fields of table ti_ser01
from z_objk_ser01
where sernr eq ti_equi-sernr
and matnr eq ti_equi-matnr.
endloop.
delete ti_ser01 where not ( kunde in s_kunnr and
bwart = '631' ).
sort ti_ser01 by matnr sernr datum descending uzeit descending.
delete adjacent duplicates from ti_ser01 comparing matnr sernr.
What this code does is fetch all these fields and then just keeps the one that's been modified at last.
I have created an index by sernr and matnr in table objk which makes it just a little bit faster.
Any helpful answer will be appreciated.
Regards,
Roberto
Edited by: Julius Bussche on Jan 27, 2009 4:29 PM
Code tags added. Please use more meaningfull subject titlesHi roberto
please avoid select statment inside loop.
use code
data: index type sy-tabix.
data : ti-ser011 type standard table of zobjk-ser01 with header line.
select matnr sernr lief_nr kunde datum uzeit bwart posnr
from z_objk_ser01 into table ti_ser01.
sort ti_ser01 by sernr matnr.
sort ti_equi by sernr matnr.
index = 1.
loop at ti_equi.
loop at ti_ser01 from index
if ti_ser01-sernr = ti_equi-sernr
and ti_ser01-matnr = ti_equi-matnr.
move-corresponding ti_ser01 to ti_ser011.
append ti_ser011.
index = sy-tabix.
exit.
endif.
endloop.
endloop.
here i have used one more internal table ti_ser011.
you can delete specific record from ti_ser01 internal table on condition. at that time u don't need to create any other internal table like ti-ser011.
in place of loop select statement---endloop.
you can use this code. I think it will help you.
please find if it is udeful. -
hi,
i have 2 tables emp1 & emp2
emp1 consist
empno month amt
001 201002 200
001 201003 100
emp2 consist
empno month amt
001 201001 100
001 201002 200
001 201003 100
i want to make a query on emp1 table where i want to show amt according to month ,if data is not available in emp1 table then only then it should take data from emp2 table ,if emp2 has that month data o/w 0.
my output should be like this
empno month amt
001 201001 100
001 201002 200
001 201003 100
regardsMay be....
SQL> WITH emp1 AS (SELECT '001' empno,'201002' mon,200 amt FROM DUAL UNION ALL
2 SELECT '001' empno,'201003' mon,100 amt FROM DUAL
3 )
4 ,emp2 AS ( SELECT '001' empno,'201001' mon,100 amt FROM DUAL UNION ALL
5 SELECT '001' empno,'201002' mon,200 amt FROM DUAL UNION ALL
6 SELECT '001' empno,'201003' mon,100 amt FROM DUAL
7 )
8 SELECT coalesce(e1.empno,e2.empno) empno,
9 coalesce(e1.mon,e2.mon) mon,
10 coalesce(e1.amt,e2.amt)amt
11 FROM emp1 e1 FULL OUTER JOIN emp2 e2
12 ON e1.empno =e2.empno
13 AND e1.mon=e2.mon
14 ORDER BY 2 ;
EMP MON AMT
001 201001 100
001 201002 200
001 201003 100 -
How to make this query more efficient
Hi, i have query to find out the count of records based on certain conditions like below.
SELECT count(*)
FROM new_orders WHERE card_number IS NOT NULL
AND exp_date IS NOT NULL
AND card_id in ( select card_id from old_orders );
There are millions of records in both the tables. , so it is taking long time to run. Is there any solution to optimize this query.....thanks for help. Bcjyou might want to give this a try.
SELECT count(*)
FROM new_orders no
WHERE no.card_number IS NOT NULL
AND no.exp_date IS NOT NULL
AND exists (select 'x'
from old_orders oo
where oo.card_id = no.card_id);it would also help if you can post the information needed as suggested by rob. -
How Can I make this query run faster
SQL> EXPLAIN PLAN FOR SELECT a.txid, a.methodid, a.serviceid, a.nodename, a.env, a.ts, a.te, a.resultcode, a.resultmessage FROM g2log.txmaster a,
2 g2log.txlookup b WHERE b.key = 'sbcgnfttxuniquedslamportid' AND b.value = 'MTC3LS733001-1-1-2-13' AND a.txid = b.txid ORDER BY ts desc;
Explained.
Elapsed: 00:00:00.01
SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
PLAN_TABLE_OUTPUT
Plan hash value: 3790334907
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 578 | 108K| 1267 (1)| 00:00:16 | | |
| 1 | PX COORDINATOR | | | | | | | |
| 2 | PX SEND QC (ORDER) | :TQ10001 | 578 | 108K| 1267 (1)| 00:00:16 | | |
| 3 | SORT ORDER BY | | 578 | 108K| 1267 (1)| 00:00:16 | | |
| 4 | PX RECEIVE | | | | | | | |
| 5 | PX SEND RANGE | :TQ10000 | | | | | | |
| 6 | NESTED LOOPS | | | | | | | |
| 7 | NESTED LOOPS | | 578 | 108K| 1266 (1)| 00:00:16 | | |
| 8 | PX PARTITION RANGE ALL | | 578 | 44506 | 109 (0)| 00:00:02 | 1 | 27 |
| 9 | TABLE ACCESS BY LOCAL INDEX ROWID| TXLOOKUP | 578 | 44506 | 109 (0)| 00:00:02 | 1 | 27 |
|* 10 | INDEX RANGE SCAN | TX_KEY_VAL | 578 | | 58 (0)| 00:00:01 | 1 | 27 |
|* 11 | INDEX UNIQUE SCAN | TXMASTER_TXID_PK | 1 | | 1 (0)| 00:00:01 | | |
| 12 | TABLE ACCESS BY GLOBAL INDEX ROWID | TXMASTER | 1 | 116 | 2 (0)| 00:00:01 | ROWID | ROWID |
Predicate Information (identified by operation id):
10 - access("B"."KEY"='sbcgnfttxuniquedslamportid' AND "B"."VALUE"='MTC3LS733001-1-1-2-13')
11 - access("A"."TXID"="B"."TXID")
25 rows selected.
I have gathered stats on the two tables as well
SQL> select count(*) from g2log.txmaster;
COUNT(*)
88812
SQL> select count(*) from g2log.txlookup;
COUNT(*)
228883I bellieve that it is disabled as well:
SQL> show parameter parallel
NAME TYPE VALUE
fast_start_parallel_rollback string LOW
parallel_adaptive_multi_user boolean TRUE
parallel_automatic_tuning boolean FALSE
parallel_degree_limit string CPU
parallel_degree_policy string MANUAL
parallel_execution_message_size integer 16384
parallel_force_local boolean FALSE
parallel_instance_group string
parallel_io_cap_enabled boolean FALSE
parallel_max_servers integer 985
parallel_min_percent integer 0
parallel_min_servers integer 0
parallel_min_time_threshold string AUTO
parallel_server boolean TRUE
parallel_server_instances integer 2
parallel_servers_target integer 1024
parallel_threads_per_cpu integer 2
recovery_parallelism integer 0 -
What can I do to make this query run faster
Hi All,
The below query is taking a long time. Is there any thing that I can do to shorten its time.
SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE, 'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME) LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID), Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID)) DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR20' then 1 when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end) TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP, SC_AGENT_EMP D, M_CAA_TRANS E where '1' <> TRIM(UPPER('S0750070Z')) and (C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in TRIM(UPPER('AR03'))OR c.co_trans_id IN TRIM (UPPER ('A020')))and C.CO_TRANS_NO = P.TRANS_NO and (C.VOID_IND = 'N' or C.VOID_IND is Null) and C.CREATED_BY = PP.PP_ID(+) and C.PROF_NO = D.PROF_NO(+) and C.CREATED_BY = D.EMP_ID (+) and TRIM(UPPER(C.CO_NO)) = TRIM(UPPER('200101586W')) and c.co_trans_id = e.trans_id (+) order by FOLIO_NO;
SQL>
SQL> show parameter user_dump_dest
NAME TYPE VALUE
user_dump_dest string /u01/app/oracle/diag/rdbms/ebi
zfile/EBIZFILE1/trace
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.2.0.2
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
optimizer_use_invisible_indexes boolean FALSE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 128
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
SQL>
SQL> column sname format a20
SQL> column pname format a20
SQL> column pval2 format a20
SQL>
SQL> select
2 sname, pname, pval1, pval2
3 from
4 sys.aux_stats$;
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 09-11-2010 14:25
SYSSTATS_INFO DSTOP 09-11-2010 14:25
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 739.734748
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
13 rows selected.
Elapsed: 00:00:00.06
SQL>
SQL> explain plan for
2 SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE, 'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME) LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID), Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID)) DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR20' then 1 when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end) TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP, SC_AGENT_EMP D, M_CAA_TRANS E where '1' <> TRIM(UPPER('S0750070Z')) and (C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in TRIM(UPPER('AR03'))OR c.co_trans_id IN TRIM (UPPER ('A020')))and C.CO_TRANS_NO = P.TRANS_NO and (C.VOID_IND = 'N' or C.VOID_IND is Null) and C.CREATED_BY = PP.PP_ID(+) and C.PROF_NO = D.PROF_NO(+) and C.CREATED_BY = D.EMP_ID (+) and TRIM(UPPER(C.CO_NO)) = TRIM(UPPER('200101586W')) and c.co_trans_id = e.trans_id (+) order by FOLIO_NO;
Explained.
Elapsed: 00:00:00.09
SQL>
SQL> set pagesize 1000;
SQL> set linesize 170;
SQL> @/u01/app/oracle/product/11.2.0/rdbms/admin/utlxpls.sql
SQL> Rem
SQL> Rem $Header: utlxpls.sql 26-feb-2002.19:49:37 bdagevil Exp $
SQL> Rem
SQL> Rem utlxpls.sql
SQL> Rem
SQL> Rem Copyright (c) 1998, 2002, Oracle Corporation. All rights reserved.
SQL> Rem
SQL> Rem NAME
SQL> Rem utlxpls.sql - UTiLity eXPLain Serial plans
SQL> Rem
SQL> Rem DESCRIPTION
SQL> Rem script utility to display the explain plan of the last explain plan
SQL> Rem command. Do not display information related to Parallel Query
SQL> Rem
SQL> Rem NOTES
SQL> Rem Assume that the PLAN_TABLE table has been created. The script
SQL> Rem utlxplan.sql should be used to create that table
SQL> Rem
SQL> Rem With SQL*plus, it is recomended to set linesize and pagesize before
SQL> Rem running this script. For example:
SQL> Rem set linesize 100
SQL> Rem set pagesize 0
SQL> Rem
SQL> Rem MODIFIED (MM/DD/YY)
SQL> Rem bdagevil 02/26/02 - cast arguments
SQL> Rem bdagevil 01/23/02 - rewrite with new dbms_xplan package
SQL> Rem bdagevil 04/05/01 - include CPU cost
SQL> Rem bdagevil 02/27/01 - increase Name column
SQL> Rem jihuang 06/14/00 - change order by to order siblings by.
SQL> Rem jihuang 05/10/00 - include plan info for recursive SQL in LE row source
SQL> Rem bdagevil 01/05/00 - add order-by to make it deterministic
SQL> Rem kquinn 06/28/99 - 901272: Add missing semicolon
SQL> Rem bdagevil 05/07/98 - Explain plan script for serial plans
SQL> Rem bdagevil 05/07/98 - Created
SQL> Rem
SQL>
SQL> set markup html preformat on
SQL>
SQL> Rem
SQL> Rem Use the display table function from the dbms_xplan package to display the last
SQL> Rem explain plan. Force serial option for backward compatibility
SQL> Rem
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
PLAN_TABLE_OUTPUT
Plan hash value: 2520189693
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 592 | 85248 | 16573 (1)| 00:03:19 |
| 1 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | 20 | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | 1 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | 20 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | 20 | 2 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | 1 (0)| 00:00:01 |
| 7 | SORT ORDER BY | | 592 | 85248 | 16573 (1)| 00:03:19 |
| 8 | NESTED LOOPS | | | | | |
| 9 | NESTED LOOPS | | 592 | 85248 | 16572 (1)| 00:03:19 |
| 10 | NESTED LOOPS OUTER | | 477 | 54855 | 15329 (1)| 00:03:04 |
| 11 | NESTED LOOPS OUTER | | 477 | 41499 | 14374 (1)| 00:02:53 |
| 12 | INLIST ITERATOR | | | | | |
|* 13 | TABLE ACCESS BY INDEX ROWID| CO_TRANS_MASTER | 477 | 22896 | 14367 (1)| 00:02:53 |
|* 14 | INDEX RANGE SCAN | IDX_CO_TRANS_ID | 67751 | | 150 (1)| 00:00:02 |
| 15 | TABLE ACCESS BY INDEX ROWID | SC_AGENT_EMP | 1 | 39 | 1 (0)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | PK_SC_AGENT_EMP | 1 | | 0 (0)| 00:00:01 |
| 17 | TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE | 1 | 28 | 2 (0)| 00:00:01 |
|* 18 | INDEX UNIQUE SCAN | SYS_C0063100 | 1 | | 1 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | IDX_PAY_DETAIL_TRANS_NO | 1 | | 2 (0)| 00:00:01 |
| 20 | TABLE ACCESS BY INDEX ROWID | PAYMENT_DETAIL | 1 | 29 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("F"."CO_TRANS_NO"=:B1)
4 - access("F"."CO_TRANS_NO"=:B1)
6 - access("F"."CO_TRANS_NO"=:B1)
13 - filter(TRIM(UPPER("SYS_ALIAS_3"."CO_NO"))='200101586W' AND ("SYS_ALIAS_3"."VOID_IND" IS NULL
OR "SYS_ALIAS_3"."VOID_IND"='N'))
14 - access("SYS_ALIAS_3"."CO_TRANS_ID"='A020' OR "SYS_ALIAS_3"."CO_TRANS_ID"='AR03' OR
"SYS_ALIAS_3"."CO_TRANS_ID"='AR20')
16 - access("SYS_ALIAS_3"."PROF_NO"="D"."PROF_NO"(+) AND
"SYS_ALIAS_3"."CREATED_BY"="D"."EMP_ID"(+))
18 - access("SYS_ALIAS_3"."CREATED_BY"="PP"."PP_ID"(+))
19 - access("SYS_ALIAS_3"."CO_TRANS_NO"="P"."TRANS_NO")
42 rows selected.
Elapsed: 00:00:00.53
SQL>
SQL>
SQL>
SQL> rollback;
Rollback complete.
Elapsed: 00:00:00.01
SQL>
SQL> rem Set the ARRAYSIZE according to your application
SQL> set autotrace traceonly arraysize 100
SQL>
SQL> alter session set tracefile_identifier = 'mytrace1';
Session altered.
Elapsed: 00:00:00.00
SQL>
SQL> rem if you're using bind variables
SQL> rem define them here
SQL>
SQL> rem variable b_var1 number
SQL> rem variable b_var2 varchar2(20)
SQL>
SQL> rem and initialize them
SQL>
SQL> rem exec :b_var1 := 1
SQL> rem exec :b_var2 := 'DIAG'
SQL> set pagesize 1000;
SQL> set linesize 170;
SQL> alter session set events '10046 trace name context forever, level 8';
Session altered.
Elapsed: 00:00:00.01
SQL> SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE, 'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME) LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID), Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID)) DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR20' then 1 when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end) TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP, SC_AGENT_EMP D, M_CAA_TRANS E where '1' <> TRIM(UPPER('S0750070Z')) and (C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in TRIM(UPPER('AR03'))OR c.co_trans_id IN TRIM (UPPER ('A020')))and C.CO_TRANS_NO = P.TRANS_NO and (C.VOID_IND = 'N' or C.VOID_IND is Null) and C.CREATED_BY = PP.PP_ID(+) and C.PROF_NO = D.PROF_NO(+) and C.CREATED_BY = D.EMP_ID (+) and TRIM(UPPER(C.CO_NO)) = TRIM(UPPER('200101586W')) and c.co_trans_id = e.trans_id (+) order by FOLIO_NO;
10 rows selected.
Elapsed: 00:03:42.27
Execution Plan
Plan hash value: 2520189693
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 592 | 85248 | 16573 (1)| 00:03:19 |
| 1 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | 20 | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | 1 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | 20 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | 20 | 2 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | 1 (0)| 00:00:01 |
| 7 | SORT ORDER BY | | 592 | 85248 | 16573 (1)| 00:03:19 |
| 8 | NESTED LOOPS | | | | | |
| 9 | NESTED LOOPS | | 592 | 85248 | 16572 (1)| 00:03:19 |
| 10 | NESTED LOOPS OUTER | | 477 | 54855 | 15329 (1)| 00:03:04 |
| 11 | NESTED LOOPS OUTER | | 477 | 41499 | 14374 (1)| 00:02:53 |
| 12 | INLIST ITERATOR | | | | | |
|* 13 | TABLE ACCESS BY INDEX ROWID| CO_TRANS_MASTER | 477 | 22896 | 14367 (1)| 00:02:53 |
|* 14 | INDEX RANGE SCAN | IDX_CO_TRANS_ID | 67751 | | 150 (1)| 00:00:02 |
| 15 | TABLE ACCESS BY INDEX ROWID | SC_AGENT_EMP | 1 | 39 | 1 (0)| 00:00:01 |
|* 16 | INDEX UNIQUE SCAN | PK_SC_AGENT_EMP | 1 | | 0 (0)| 00:00:01 |
| 17 | TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE | 1 | 28 | 2 (0)| 00:00:01 |
|* 18 | INDEX UNIQUE SCAN | SYS_C0063100 | 1 | | 1 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | IDX_PAY_DETAIL_TRANS_NO | 1 | | 2 (0)| 00:00:01 |
| 20 | TABLE ACCESS BY INDEX ROWID | PAYMENT_DETAIL | 1 | 29 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("F"."CO_TRANS_NO"=:B1)
4 - access("F"."CO_TRANS_NO"=:B1)
6 - access("F"."CO_TRANS_NO"=:B1)
13 - filter(TRIM(UPPER("SYS_ALIAS_3"."CO_NO"))='200101586W' AND ("SYS_ALIAS_3"."VOID_IND" IS NULL
OR "SYS_ALIAS_3"."VOID_IND"='N'))
14 - access("SYS_ALIAS_3"."CO_TRANS_ID"='A020' OR "SYS_ALIAS_3"."CO_TRANS_ID"='AR03' OR
"SYS_ALIAS_3"."CO_TRANS_ID"='AR20')
16 - access("SYS_ALIAS_3"."PROF_NO"="D"."PROF_NO"(+) AND
"SYS_ALIAS_3"."CREATED_BY"="D"."EMP_ID"(+))
18 - access("SYS_ALIAS_3"."CREATED_BY"="PP"."PP_ID"(+))
19 - access("SYS_ALIAS_3"."CO_TRANS_NO"="P"."TRANS_NO")
Statistics
51 recursive calls
0 db block gets
651812 consistent gets
92202 physical reads
0 redo size
1594 bytes sent via SQL*Net to client
524 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
10 rows processed
SQL>
SQL> disconnect
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> Thanks in advance!Hi Raj,
I have given the output below as you requested....
QL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID 0taz7ckjm41yv, child number 1
SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE,
'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME)
LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID),
Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID))
DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select
nvl(base_trans_id,co_trans_id) from co_form5a_trans f where
f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when
decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from
co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR2
0' then 1 when decode(c.co_trans_id,'A020',(select
nvl(base_trans_id,co_trans_id) from co_form5a_trans f where
f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end)
TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP,
SC_AGENT_EMP D, M_CAA_TRANS E where '1' <> TRIM(UPPER('S0750070Z')) and
(C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in
TRIM(UPPER('AR03'))OR c.co
Plan hash value: 4175354585
| Id | Operation | Name | E-Rows | OMem | 1Mem | Used-Mem |
| 0 | SELECT STATEMENT | | | | | |
| 1 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | | | |
|* 2 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | | |
| 3 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | | | |
|* 4 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | | |
| 5 | TABLE ACCESS BY INDEX ROWID | CO_FORM5A_TRANS | 1 | | | |
|* 6 | INDEX UNIQUE SCAN | SYS_C0059692 | 1 | | | |
| 7 | SORT ORDER BY | | 12 | 2048 | 2048 | 2048 (0)|
| 8 | NESTED LOOPS | | | | | |
| 9 | NESTED LOOPS | | 12 | | | |
| 10 | NESTED LOOPS OUTER | | 10 | | | |
| 11 | NESTED LOOPS OUTER | | 10 | | | |
|* 12 | TABLE ACCESS FULL | CO_TRANS_MASTER | 10 | | | |
| 13 | TABLE ACCESS BY INDEX ROWID| SC_AGENT_EMP | 1 | | | |
|* 14 | INDEX UNIQUE SCAN | PK_SC_AGENT_EMP | 1 | | | |
| 15 | TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE | 1 | | | |
|* 16 | INDEX UNIQUE SCAN | SYS_C0063100 | 1 | | | |
|* 17 | INDEX RANGE SCAN | IDX_PAY_DETAIL_TRANS_NO | 1 | | | |
| 18 | TABLE ACCESS BY INDEX ROWID | PAYMENT_DETAIL | 1 | | | |
Predicate Information (identified by operation id):
2 - access("F"."CO_TRANS_NO"=:B1)
4 - access("F"."CO_TRANS_NO"=:B1)
6 - access("F"."CO_TRANS_NO"=:B1)
12 - filter((INTERNAL_FUNCTION("SYS_ALIAS_3"."CO_TRANS_ID") AND
TRIM(UPPER("SYS_ALIAS_3"."CO_NO"))='200101586W' AND ("SYS_ALIAS_3"."VOID_IND" IS NULL OR
"SYS_ALIAS_3"."VOID_IND"='N')))
14 - access("SYS_ALIAS_3"."PROF_NO"="D"."PROF_NO" AND "SYS_ALIAS_3"."CREATED_BY"="D"."EMP_ID")
16 - access("SYS_ALIAS_3"."CREATED_BY"="PP"."PP_ID")
17 - access("SYS_ALIAS_3"."CO_TRANS_NO"="P"."TRANS_NO")
Note
- cardinality feedback used for this statement
- Warning: basic plan statistics not available. These are only collected when:
* hint 'gather_plan_statistics' is used for the statement or
* parameter 'statistics_level' is set to 'ALL', at session or system level
65 rows selected. -
Re: How to make this forum run fast
I counted till eleven, but since I'm a rather quick counter, I'd say about 7 seconds as well.
Could it be that y'all are using Firefox? I'm on IE7.
®
(suspecting commie influence since '77)sabre150 wrote:
kajbj wrote:
CeciNEstPasUnProgrammeur wrote:
I counted till eleven, but since I'm a rather quick counter, I'd say about 7 seconds as well.
Could it be that y'all are using Firefox? I'm on IE7.
®
(suspecting commie influence since '77)Strange. I tried with IE 7. Loading the main page, about 45 seconds, loading this thread about 30 seconds, getting to the reply page about 3-4 seconds.I find the site blindingly fast! Certainly less than 45 seconds to load the man page and very very much less that 30 seconds for this page. Both typically 1 second with the login page taking about 3 seconds.
Now if only I could access ALL the pages without Server Error
This server has encountered an internal error which prevents it from fulfilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log.
What forum? id 5? -
WITH
MEMBER [FYDay].[DateHierarchy].[CurrentDay] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[PreviousDay] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .PREVMEMBER }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay1] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(1) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay2] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(2) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay3] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(3) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay4] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(4) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay5] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(5) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay6] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(6) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay7] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(7) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[PTD] AS AGGREGATE(PERIODSTODATE([FYDay].[DateHierarchy].[FPERIOD],
[FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014]
), [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[WTD] AS AGGREGATE(PERIODSTODATE([FYDay].[DateHierarchy].[FWEEK],
[FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014]
), [Measures].CURRENTMEMBER)
SELECT
[FYDay].[DateHierarchy].[WTD],
[FYDay].[DateHierarchy].[PTD],
[FYDay].[DateHierarchy].[PreviousDay],
[FYDay].[DateHierarchy].[CurrentDay],
[FYDay].[DateHierarchy].[CurrentDay1],
[FYDay].[DateHierarchy].[CurrentDay2],
[FYDay].[DateHierarchy].[CurrentDay3],
[FYDay].[DateHierarchy].[CurrentDay4],
[FYDay].[DateHierarchy].[CurrentDay5],
[FYDay].[DateHierarchy].[CurrentDay6],
[FYDay].[DateHierarchy].[CurrentDay7]
} ON COLUMNS,
[Measures].[Store Budget],
[MEASURES].[SNAPSHOTSOLDAMOUNT],
[MEASURES].[SHIPPEDAMOUNT],
[MEASURES].[SHIPPED VS SOLD],
[Measures].[% To Budget]
{[STOREMASTER].[SERVICINGDC].[SERVICINGDC].ALLMEMBERS}
)} ON ROWS
from ( select {[STOREMASTER].[SERVICINGDC].&[Houston]} on columns
FROM [Model]Hi Ramparasad,
In your query, you add a measures and dimension on Row axis which is not supported in query designer in SSRS. Please use the query below.
WITH
MEMBER [FYDay].[DateHierarchy].[CurrentDay] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[PreviousDay] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .PREVMEMBER }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay1] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(1) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay2] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(2) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay3] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(3) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay4] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(4) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay5] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(5) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay6] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(6) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[CurrentDay7] AS AGGREGATE(
{ [FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014] .LEAD(7) }
, [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[PTD] AS AGGREGATE(PERIODSTODATE([FYDay].[DateHierarchy].[FPERIOD],
[FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014]
), [Measures].CURRENTMEMBER)
MEMBER [FYDay].[DateHierarchy].[WTD] AS AGGREGATE(PERIODSTODATE([FYDay].[DateHierarchy].[FWEEK],
[FYDay].[DateHierarchy].[FYEAR].&[2014].&[4].&[10].&[41].&[09/11/2014]
), [Measures].CURRENTMEMBER)
SELECT
[Measures].[Store Budget],
[MEASURES].[SNAPSHOTSOLDAMOUNT],
[MEASURES].[SHIPPEDAMOUNT],
[MEASURES].[SHIPPED VS SOLD],
[Measures].[% To Budget]
}ON COLUMNS,
{ [FYDay].[DateHierarchy].[WTD],
[FYDay].[DateHierarchy].[PTD],
[FYDay].[DateHierarchy].[PreviousDay],
[FYDay].[DateHierarchy].[CurrentDay],
[FYDay].[DateHierarchy].[CurrentDay1],
[FYDay].[DateHierarchy].[CurrentDay2],
[FYDay].[DateHierarchy].[CurrentDay3],
[FYDay].[DateHierarchy].[CurrentDay4],
[FYDay].[DateHierarchy].[CurrentDay5],
[FYDay].[DateHierarchy].[CurrentDay6],
[FYDay].[DateHierarchy].[CurrentDay7]
{[STOREMASTER].[SERVICINGDC].[SERVICINGDC].ALLMEMBERS}
} ON ROWS
from ( select {[STOREMASTER].[SERVICINGDC].&[Houston]} on columns
FROM [Model]
Regards,
Charlie Liao
TechNet Community Support -
How to make this select statement faster?
this statement is really taking long time to process.
in bseg table as vbeln is not primary key or seconday key, i guess thz the reason it is taking so much time ,,,
can anyone help me to sort this out... ??
any fun mod to get the data of bseg cluster table by giving vbeln?/
or any other conditions to reduce the processing time?
clear t_vbrkvbrp.
sort t_vbrkvbrp by vbeln.
loop at t_vbrkvbrp.
at new vbeln.
select bukrs belnr vbeln
from bseg
into corresponding fields of table t_temp
where bukrs = t_vbrkvbrp-bukrs
and vbeln = t_vbrkvbrp-vbeln.
endat.
endloop.
SELECT bukrs belnr buzid koart shkzg dmbtr vbeln hkont kunnr werks
FROM bseg
INTO TABLE t_bseg
for all entries in t_temp
WHERE hkont IN s_hkont
AND bukrs = t_temp-bukrs
AND belnr = t_temp-belnr
AND buzid = ' '
AND koart = 'S'
AND shkzg = 'H'.
i need to get the g/l account number for the above condition type so i have to use bseg table
Message was edited by:
shahid mohammed syedShahid,
Usually BSEG SELECTs are slow as it is a Clu8ster table. More over you are not passing the PKeys in the WHERE condition. That's alcso one reason for slow retrieval. You can also use the table BSIS (Accounting: Secondary Index for G/L Accounts) for the G/L accounts. But first of all, I suggest you cnange your where condition as below:
SELECT bukrs belnr buzid koart shkzg dmbtr vbeln hkont kunnr werks
FROM bseg
INTO TABLE t_bseg
for all entries in t_temp
WHERE bukrs = t_temp-bukrs
AND belnr = t_temp-belnr
AND buzid = ' '
AND koart = 'S'
AND shkzg = 'H'
<b>AND hkont IN s_hkont.</b>
Not much diff. I just re-ordered the condition based on the order of BSEG fields... Lemme know if it helps.
Regards,
Karthik
Message was edited by:
Karthik -
How to make this query efficient
create table temp)au_sa_poi_geocoding2 as select idx, address_form, suburb_form
from temp_au_Sa_poi_geocoding a where idx not in (select idx from gc1_Sa_sub where status='m' ) and exists (select null from sh_poi_small cites c
where upper (trim(a.suburb_form))=c.city)
one table contain round 74214 records while the other has less than that.
the tables were not indexed, i created index using the following commands.
create index sa_idx on temp_au_sa_poi_geocoding(idx)
create index sa1_idx on gc1_sa_sub(idx)
anyhelp would be appreciated.
thankscreate index sa0_idx on temp_au_Sa_poi_geocoding(upper(trim(suburb_form)));
create index sa1_idx on gc1_sa_sub(status,idx); -- instead of only (idx)
create index sh_idx on sh_poi_small (city);
then try as follows
create table temp_au_sa_poi_geocoding2 as select idx,
address_form, suburb_form
from temp_au_Sa_poi_geocoding a where idx not in
(select /*+ index gc1 */ idx from gc1_Sa_sub gc1 where status='m' ) and
exists (select /*+ index_join c a */ null from sh_poi_small cites c
where upper (trim(a.suburb_form))=c.city)
however effects of indexes will vary by cardinality. -
hi,
i have a product table like
product month1 month2 month3 .................
soap 1200 1256 1895 ............
i want use a query where i can select column name with a parameter.
like
select month||:num from product;
in num variable it cud be 1 to 10 of value that is dependent on my program.
so how to make this query .
thxsHi,
Here is an example that i am helpful.
In the example , I am using a table 'table_name' which contains columns like
assign_attribute1
assign_attribute2
assign_attribute15
Now I will pass any number from 1 to 15 to the function.
create or replace procedure pass_col_number(v_number varchar2) as
v_sql varchar2(2000);
v_assign_attribute1 varchar2(150);
begin
v_sql := 'select assign_attribute'||v_number||' from table_name where person_id = 1345';
execute immediate v_sql into v_assign_attribute1;
dbms_output.put_line('v_assign_attribute1='||v_assign_attribute1);
end;Edited by: Sreekanth Munagala on Dec 18, 2008 1:18 AM -
How to write this query to filter combination of few values
Hi,
I have a table CHIMM which is a transaction table and contains information of the vaccines given to a child.
columns are: child_id, vacc_id, vacc_given_dt. I have to query for remaining vaccines.
HEXA is a vaccine_id which is composite vaccine of DPT1,POL1,HBV1 & HIB1 (vaccine ids).
I want to write to query if any of DPT1,POL1,HBV1 & HIB1 given then HEXA should not be displayed in the result.
OR
if HEXA is given then of course any of DPT1,POL1,HBV1 & HIB1 should not be displayed in the result.
How to write this query?
RegardsHi,
I'm still not sure what the output you want from that sample data is. Do you just want the child_ids, like this
CHILD_ID
3
4? If so, here's one way to get them:
WITH all_vacc_ids AS
SELECT c.child_id
, c.vacc_id AS child_vacc_id
, v.vacc_id
, COUNT ( CASE
WHEN c.vacc_id = 'HEXA'
THEN 1
END
) OVER ( PARTITION BY c.child_id
) AS hexa_itself
FROM vacc v
LEFT OUTER JOIN chimm c PARTITION BY (c.child_id)
ON c.vacc_id = v.vacc_id
WHERE v.vacc_desc = 'HEXA' -- See note below
SELECT child_id
FROM all_vacc_ids
WHERE child_vacc_id IS NULL
AND vacc_id != 'HEXA'
AND hexa_itself = 0
GROUP BY child_id
rha2 wrote:there are alot of vaccines, i just put 3 for example. this query gives error: invalid relational operatorAre you saying that the vacc table contains other rows, but those other rows are not needed for this problem? It would be good if you included an example in the sample data. The query above considers only the rows in vacc where vacc_desc='HEXA'. You can have other rows in the vacc table, but they won't affect the output of this query. The query above makes no assumptions about the number of rows that have vacc_desc='HEXA'; it will report all child_ids who are missing any of them, regardless of the number (assuming the child does not have the 'HEXA' vacc_id itself, like child_id=1).
You still haven't said which version of Oracle you're using. The query above will work in Oracle 10 (and higher). -
How To Make Search Query Showing the Result As List of Buttons.
Can some one give me an idea how to start to make a Search Query showing the results as list of buttons.. i have already have my buttons with names. i just dont know how to make a search query.
this is my on screen keyboard i made..
im making a system that the result were a list of buttons.. showing like this
This was supposed to be the output of the query that i need to do..
Please help me.. i just need a idea or tips how to make this one.Here is code I posted recently for another question
Public Class Form1
Const BUTTON_SIZE As Integer = 20
Const SPACE As Integer = 5
Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Dim buttons As New List(Of List(Of MyRadioButton))
For row = 1 To 6
Dim newRow As New List(Of MyRadioButton)
buttons.Add(newRow)
For col = 1 To 6
Dim button As New MyRadioButton()
button.row = row
button.col = col
button.Height = BUTTON_SIZE
button.Width = BUTTON_SIZE
button.Left = col * (BUTTON_SIZE + SPACE)
button.Top = row * (BUTTON_SIZE + SPACE)
button.Name = String.Format("radGr1{0}_{1}", row.ToString(), col.ToString())
Me.Controls.Add(button)
newRow.Add(button)
AddHandler button.CheckedChanged, AddressOf Radio_Change
Next col
Next row
End Sub
Private Sub Radio_Change(ByVal sender As Object, ByVal e As System.EventArgs)
Dim button As MyRadioButton = CType(sender, MyRadioButton)
Dim row As Integer = button.row
Dim col As Integer = button.col
End Sub
End Class
Public Class MyRadioButton
Inherits RadioButton
Public row As Integer
Public col As Integer
End Class
jdweng -
How to make this work with Firefox, HELP!
Downloading for Real-player, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. How to make this work with Firefox, I like not to use Microsoft products, and I really like Firefox 7.0.1!!!! HELP!
-> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
* Advanced panel -> Network tab
* place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
* Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
* click OK on Options window
* Restart Firefox
Check and tell if ts working.
Maybe you are looking for
-
Sync conflicts between Exchange and Gmail/IMAP/Mobile Me accounts
Hello. I have managed to configure my exchange account in Mail, and it seemed to be working fine until yesterday. Today however, I am experiencing some odd behaviour in my mail accounts: - My two Gmail accounts (IMAP, syncing through Mobile me) are m
-
Garageband version 10.0.2 vs. version 6.0.5?
This is more of an opinion survey than anything. Just wondering how other Garageband users are finding the new version so far (version 10.0.2)? I've mostly stuck to the old one (version 6.0.5), since I know how to do everything I need to do with it.
-
On my MBP, what does the uppercase number over calendar represent?
I'm running the latest version of Mountain Lion (10.8.2). I have Calendar in my Dock. In the upper right of the calendar icon is a red circle with a number (4 in this case) in it. What does that signify? When I look at my calendar I have three ma
-
Very urgent - validation failed in field
hello friedns, i have an issue field called weight in ADF page. i am very new to ADF Technolgy. 1) if user eneters invalid value enters in weight filed it will show alert that Weight - Value should be 0 to 9999.999 only ,i cliked the ok of that alert
-
What version of 10GiAS is compatible with Integration B2B & BPEL
I believe Oracle is going to release 10gr3 (10.1.3.1) release of Middleware which is bundled as SOA suite along with other suites BPA/EDA etc We were told earlier that 10.1.3 is not compatible with Integration B2B as B2B needs 10.1.2 BPEL Designer. C