Tuning required for the query
Hi,
I am just wondering what could be the best SQL for the following scenario.
Table 1 Table2
COL1 COL2 COL3 COL1 COL2 COL3
AAA 123 10 AAA 123 12
AAA 123 12
AAA 123 14
AAA 456 10
AAA 456 12
AAA 456 14
Given the above data, I want only the AAA/123/10 and AAA/123/14 records from table1, and leave the others alone.
The tables are huge (200 million) and indexed on all the three columns and my SQL is taking much time to complete.
SQL i have used
select col1, col2, col3 from (
select a.col1, a.col2, a.col3, b.col3 col4 from
table1 a
left join
table2 b
on
a.col1 = b.col1 and
a.col2 = b.col2 and
a.col3 = b.col3
where exists (select 1 from table2 c where a.col1 = c.col1 and a.col2 = c.col2)
) x
where x.col4 is null
Can anyone give me better solution than this?
Depending on your data, there is a good possibility that the intermediate result set, after the outerjoin from table1 to table2, is even more huge than the original tables. This might impact the time it takes to process your query in a negative way.
The next query does something similar, but with a smaller intermediate result sets and is therefore probably a bit faster. At least it's worth the try. Please let us know the impact.
SQL> select t1.col1
2 , t1.col2
3 , t1.col3
4 from table1 t1
5 where exists
6 ( select null
7 from table2 t2
8 where t2.col1 = t1.col1
9 and t2.col2 = t1.col2
10 )
11 minus
12 select t2.col1
13 , t2.col2
14 , t2.col3
15 from table2 t2
16 /
COL COL2 COL3
AAA 123 10
AAA 123 14
2 rows selected.Regards,
Rob.
Similar Messages
-
Tuning tricks for the query.
Hi Everyone,
This is my DB version @ production.
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
We have a query, which is running more than 3 mins at production as we have 40 millions active records for almost 2 million active patients.
So clearly the active record percentage is 98. We have indexes on all required field values last date of computed statistics was 1st Jan 2014.
But we are unable achieve the performance from the query. If we are making it tightly coupled with parent - child relationship, then it's generating cost
value more than 2 million. So we tried some sub-queries but still the cost value is in million. Please do have a look at the query and suggest me something where
I can meliorate this. We can't go change DB structure straight away right now. So what needs to be done here? Please suggest something.
Query:-
select distinct
(select p.last_name || ', ' || p.first_name
from patient p
where p.patient_id = loc.patient_id) as patient_name,
(select p.external_id
from patient p
where p.patient_id = loc.patient_id) as external_id,
(select p.spectra_mrn
from patient p
where p.patient_id = loc.patient_id) as spectra_mrn,
ord.requisition_number as requisition_number,
f.facility_name as facility_name,
f.facility_id as facility_id,
(select fad.account_type as modality
from patient p,
patient_facility_modality pfm,
facility_account_modality fam,
facility_account_detail fad
where p.patient_id = pfm.patient_id
and pfm.facility_account_modality_id =
fam.facility_account_modality_id
and fam.facility_account_detail_id = fad.facility_account_detail_id
and p.patient_id = loc.patient_id
and pfm.facility_id = loc.facility_id) as modality,
(select fad.account_number as account_number
from patient p,
patient_facility_modality pfm,
facility_account_modality fam,
facility_account_detail fad
where p.patient_id = pfm.patient_id
and pfm.facility_account_modality_id =
fam.facility_account_modality_id
and fam.facility_account_detail_id = fad.facility_account_detail_id
and p.patient_id = loc.patient_id
and pfm.facility_id = loc.facility_id) as account_number,
(select fad.hlab_num as hlab_num
from patient p,
patient_facility_modality pfm,
facility_account_modality fam,
facility_account_detail fad
where p.patient_id = pfm.patient_id
and pfm.facility_account_modality_id =
fam.facility_account_modality_id
and fam.facility_account_detail_id = fad.facility_account_detail_id
and p.patient_id = loc.patient_id
and pfm.facility_id = loc.facility_id) as hlab_num,
loc.order_draw_dt as draw_dt,
c.corporation_name as corporation_name,
c.corporation_acronym as acronym,
loc.patient_id,
loct.test_id
from lab_order_occ loc,
lab_order_occ_test loct,
facility f,
corporation c,
order_requisition_header ord
where loc.lab_order_occ_id = loct.lab_order_occ_id
and loc.facility_id = f.facility_id
and f.corporation_id = c.corporation_id
and ord.patient_id = loc.patient_id
and ord.facility_id = loc.facility_id
and ord.draw_dt = loc.order_draw_dt
and loc.order_draw_dt between trunc(sysdate) - 7 and trunc(sysdate)
and loc.status = 'A'
and loc.msg_sent_to_lab_yn = 'Y'
and loct.status <> 'R'
and loct.test_id in (
select test_id
from test_required
where required_test_code in (
select test_code
from interface_adt_aoe_master))
and
(select count(*) from interface_adt_aoe_master where source_system = corporation_acronym
and test_code = (select test_code from test where test_id=(select aoe_test_id from lab_order_occ_test_aoe where lab_order_occ_test_id= loct.lab_order_occ_test_id)))
!=
(select count(*) from EMR_ADTAOE_DTL where patient_id = loc.patient_id and facility_id = loc.facility_id and (
(test_id = (select aoe_test_id from lab_order_occ_test_aoe where lab_order_occ_test_id= loct.lab_order_occ_test_id) and trunc(draw_date) like trunc(loc.order_draw_dt))
or (test_id = (select aoe_test_id from lab_order_occ_test_aoe where LAB_ORDER_OCC_TEST_ID= loct.lab_order_occ_test_id) and trunc(draw_date)= trunc(to_date('12-31-2999','mm-dd-yyyy')))
and STATUS = 'Y' and ANSWER is not null)
Execution Plan @ QAT environment
explain plan succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 2140167730
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 399 | 59451 | 6293 (1)| 00:01:16 |
| 1 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 21 | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 11 | 2 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID | PATIENT | 1 | 12 | 2 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 43 | 5 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 1 | 29 | 4 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1 | 19 | 3 (0)| 00:00:01 |
|* 10 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | 5 | 1 (0)| 00:00:01 |
|* 11 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 1 | 14 | 2 (0)| 00:00:01 |
| 12 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_MODALITY | 1 | 10 | 1 (0)| 00:00:01 |
|* 13 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_MODALITY_PK | 1 | | 0 (0)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_DETAIL | 1 | 14 | 1 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_DETAIL_PK | 1 | | 0 (0)| 00:00:01 |
| 16 | NESTED LOOPS | | 1 | 40 | 5 (0)| 00:00:01 |
| 17 | NESTED LOOPS | | 1 | 29 | 4 (0)| 00:00:01 |
| 18 | NESTED LOOPS | | 1 | 19 | 3 (0)| 00:00:01 |
|* 19 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | 5 | 1 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 1 | 14 | 2 (0)| 00:00:01 |
| 21 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_MODALITY | 1 | 10 | 1 (0)| 00:00:01 |
|* 22 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_MODALITY_PK | 1 | | 0 (0)| 00:00:01 |
| 23 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_DETAIL | 1 | 11 | 1 (0)| 00:00:01 |
|* 24 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_DETAIL_PK | 1 | | 0 (0)| 00:00:01 |
| 25 | NESTED LOOPS | | 1 | 42 | 5 (0)| 00:00:01 |
| 26 | NESTED LOOPS | | 1 | 29 | 4 (0)| 00:00:01 |
| 27 | NESTED LOOPS | | 1 | 19 | 3 (0)| 00:00:01 |
|* 28 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | 5 | 1 (0)| 00:00:01 |
|* 29 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 1 | 14 | 2 (0)| 00:00:01 |
| 30 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_MODALITY | 1 | 10 | 1 (0)| 00:00:01 |
|* 31 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_MODALITY_PK | 1 | | 0 (0)| 00:00:01 |
| 32 | TABLE ACCESS BY INDEX ROWID | FACILITY_ACCOUNT_DETAIL | 1 | 13 | 1 (0)| 00:00:01 |
|* 33 | INDEX UNIQUE SCAN | FACILITY_ACCOUNT_DETAIL_PK | 1 | | 0 (0)| 00:00:01 |
| 34 | HASH UNIQUE | | 399 | 59451 | 6293 (1)| 00:01:16 |
|* 35 | FILTER | | | | | |
|* 36 | FILTER | | | | | |
|* 37 | HASH JOIN | | 399 | 59451 | 6285 (1)| 00:01:16 |
| 38 | TABLE ACCESS FULL | CORPORATION | 291 | 11640 | 3 (0)| 00:00:01 |
| 39 | NESTED LOOPS | | 399 | 43491 | 6282 (1)| 00:01:16 |
|* 40 | HASH JOIN | | 2113 | 216K| 6281 (1)| 00:01:16 |
| 41 | TABLE ACCESS FULL | TEST_REQUIRED | 1184 | 10656 | 5 (0)| 00:00:01 |
|* 42 | TABLE ACCESS BY INDEX ROWID | LAB_ORDER_OCC_TEST | 8 | 144 | 5 (0)| 00:00:01 |
| 43 | NESTED LOOPS | | 1345 | 126K| 6276 (1)| 00:01:16 |
|* 44 | HASH JOIN | | 170 | 13260 | 5425 (1)| 00:01:06 |
|* 45 | HASH JOIN | | 170 | 8670 | 5403 (1)| 00:01:05 |
|* 46 | TABLE ACCESS BY INDEX ROWID| LAB_ORDER_OCC | 12775 | 336K| 569 (1)| 00:00:07 |
|* 47 | INDEX SKIP SCAN | LAB_ORDER_OCC_IX_07 | 2218 | | 13 (8)| 00:00:01 |
|* 48 | TABLE ACCESS BY INDEX ROWID| ORDER_REQUISITION_HEADER | 56952 | 1334K| 4833 (1)| 00:00:58 |
|* 49 | INDEX SKIP SCAN | ORDER_REQUISITION_HEADER_IX_04 | 4905 | | 1707 (1)| 00:00:21 |
| 50 | TABLE ACCESS FULL | FACILITY | 4252 | 112K| 22 (0)| 00:00:01 |
|* 51 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_IX_01 | 8 | | 2 (0)| 00:00:01 |
|* 52 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 1 | 4 | 0 (0)| 00:00:01 |
| 53 | SORT AGGREGATE | | 1 | 12 | | |
|* 54 | TABLE ACCESS BY INDEX ROWID | INTERFACE_ADT_AOE_MASTER | 1 | 12 | 2 (0)| 00:00:01 |
|* 55 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 4 | | 1 (0)| 00:00:01 |
| 56 | TABLE ACCESS BY INDEX ROWID | TEST | 1 | 9 | 2 (0)| 00:00:01 |
|* 57 | INDEX UNIQUE SCAN | TEST_PK | 1 | | 1 (0)| 00:00:01 |
|* 58 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
| 59 | SORT AGGREGATE | | 1 | 29 | | |
|* 60 | FILTER | | | | | |
|* 61 | TABLE ACCESS BY INDEX ROWID | EMR_ADTAOE_DTL | 1 | 29 | 30 (0)| 00:00:01 |
|* 62 | INDEX RANGE SCAN | EMR_ADTAOE_DTL_IX_01 | 174 | | 3 (0)| 00:00:01 |
|* 63 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
|* 64 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
Query Block Name / Object Alias (identified by operation id):
1 - SEL$2 / P@SEL$2
2 - SEL$2 / P@SEL$2
3 - SEL$3 / P@SEL$3
4 - SEL$3 / P@SEL$3
5 - SEL$4 / P@SEL$4
6 - SEL$4 / P@SEL$4
7 - SEL$5
10 - SEL$5 / P@SEL$5
11 - SEL$5 / PFM@SEL$5
12 - SEL$5 / FAM@SEL$5
13 - SEL$5 / FAM@SEL$5
14 - SEL$5 / FAD@SEL$5
15 - SEL$5 / FAD@SEL$5
16 - SEL$6
19 - SEL$6 / P@SEL$6
20 - SEL$6 / PFM@SEL$6
21 - SEL$6 / FAM@SEL$6
22 - SEL$6 / FAM@SEL$6
23 - SEL$6 / FAD@SEL$6
24 - SEL$6 / FAD@SEL$6
25 - SEL$7
28 - SEL$7 / P@SEL$7
29 - SEL$7 / PFM@SEL$7
30 - SEL$7 / FAM@SEL$7
31 - SEL$7 / FAM@SEL$7
32 - SEL$7 / FAD@SEL$7
33 - SEL$7 / FAD@SEL$7
34 - SEL$AA3B83ED
38 - SEL$AA3B83ED / C@SEL$1
41 - SEL$AA3B83ED / TEST_REQUIRED@SEL$8
42 - SEL$AA3B83ED / LOCT@SEL$1Hi Karthick,
Thanks for the response. The suggestion is really good. But we have some tables accessed like "lab_order_occ" which size is more than 8GB also having no partitions. If I'll ask for altering DB structure, this will be finalized not less than 6 months. Please do have a look at the plan now. It's generating more cost.
explain plan succeeded.
PLAN_TABLE_OUTPUT
Plan hash value: 2523654849
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1057 | 293K| 25324 (2)| 00:05:04 |
|* 1 | FILTER | | | | | |
|* 2 | HASH JOIN RIGHT SEMI | | 1057 | 293K| 25317 (2)| 00:05:04 |
| 3 | VIEW | VW_NSO_1 | 224 | 2912 | 5 (0)| 00:00:01 |
|* 4 | FILTER | | | | | |
| 5 | NESTED LOOPS | | 224 | 2912 | 5 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | TEST_REQUIRED | 1184 | 10656 | 5 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 1 | 4 | 0 (0)| 00:00:01 |
|* 8 | TABLE ACCESS BY INDEX ROWID | LAB_ORDER_OCC_TEST | 8 | 144 | 5 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1345 | 355K| 25311 (2)| 00:05:04 |
|* 10 | HASH JOIN | | 170 | 43010 | 24460 (2)| 00:04:54 |
| 11 | TABLE ACCESS FULL | CORPORATION | 291 | 11640 | 3 (0)| 00:00:01 |
|* 12 | HASH JOIN | | 170 | 36210 | 24457 (2)| 00:04:54 |
| 13 | NESTED LOOPS OUTER | | 170 | 31620 | 24434 (2)| 00:04:54 |
|* 14 | HASH JOIN | | 170 | 14960 | 5403 (1)| 00:01:05 |
|* 15 | TABLE ACCESS BY INDEX ROWID | LAB_ORDER_OCC | 12775 | 598K| 569 (1)| 00:00:07 |
|* 16 | INDEX SKIP SCAN | LAB_ORDER_OCC_IX_07 | 2218 | | 13 (8)| 00:00:01 |
|* 17 | TABLE ACCESS BY INDEX ROWID | ORDER_REQUISITION_HEADER | 56952 | 2224K| 4833 (1)| 00:00:58 |
|* 18 | INDEX SKIP SCAN | ORDER_REQUISITION_HEADER_IX_04 | 4905 | | 1707 (1)| 00:00:21 |
| 19 | VIEW PUSHED PREDICATE | | 1 | 98 | 112 (2)| 00:00:02 |
|* 20 | HASH JOIN | | 93 | 8835 | 112 (2)| 00:00:02 |
|* 21 | HASH JOIN | | 93 | 6231 | 56 (2)| 00:00:01 |
|* 22 | HASH JOIN | | 93 | 5301 | 48 (3)| 00:00:01 |
| 23 | NESTED LOOPS | | 68 | 2924 | 44 (0)| 00:00:01 |
| 24 | TABLE ACCESS BY INDEX ROWID| PATIENT | 1 | 34 | 2 (0)| 00:00:01 |
|* 25 | INDEX UNIQUE SCAN | PATIENT_PK | 1 | | 1 (0)| 00:00:01 |
| 26 | TABLE ACCESS BY INDEX ROWID| LAB_ORDER_OCC | 68 | 612 | 42 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | LAB_ORDER_OCC_IX_02 | 53 | | 2 (0)| 00:00:01 |
|* 28 | INDEX RANGE SCAN | PATIENT_FACILITY_MOD_IX_01 | 111 | 1554 | 3 (0)| 00:00:01 |
| 29 | TABLE ACCESS FULL | FACILITY_ACCOUNT_MODALITY | 9159 | 91590 | 8 (0)| 00:00:01 |
| 30 | TABLE ACCESS FULL | FACILITY_ACCOUNT_DETAIL | 7266 | 198K| 55 (0)| 00:00:01 |
| 31 | TABLE ACCESS FULL | FACILITY | 4252 | 112K| 22 (0)| 00:00:01 |
|* 32 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_IX_01 | 8 | | 2 (0)| 00:00:01 |
| 33 | SORT AGGREGATE | | 1 | 12 | | |
|* 34 | TABLE ACCESS BY INDEX ROWID | INTERFACE_ADT_AOE_MASTER | 1 | 12 | 2 (0)| 00:00:01 |
|* 35 | INDEX RANGE SCAN | INTERFACE_ADT_AOE_MASTER_IX_01 | 4 | | 1 (0)| 00:00:01 |
| 36 | TABLE ACCESS BY INDEX ROWID | TEST | 1 | 9 | 2 (0)| 00:00:01 |
|* 37 | INDEX UNIQUE SCAN | TEST_PK | 1 | | 1 (0)| 00:00:01 |
|* 38 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
| 39 | SORT AGGREGATE | | 1 | 29 | | |
|* 40 | FILTER | | | | | |
|* 41 | TABLE ACCESS BY INDEX ROWID | EMR_ADTAOE_DTL | 1 | 29 | 30 (0)| 00:00:01 |
|* 42 | INDEX RANGE SCAN | EMR_ADTAOE_DTL_IX_01 | 174 | | 3 (0)| 00:00:01 |
|* 43 | INDEX RANGE SCAN | LAB_ORDER_OCC_TEST_AOE_PK | 1 | 10 | 3 (0)| 00:00:01 |
Query Block Name / Object Alias (identified by operation id):
1 - SEL$19EEE7EA
3 - SEL$9DB3EFF9 / VW_NSO_1@SEL$19EEE7EA
4 - SEL$9DB3EFF9
6 - SEL$9DB3EFF9 / TEST_REQUIRED@SEL$3
7 - SEL$9DB3EFF9 / INTERFACE_ADT_AOE_MASTER@SEL$4
8 - SEL$19EEE7EA / LOCT@SEL$1
11 - SEL$19EEE7EA / C@SEL$1
15 - SEL$19EEE7EA / LOC@SEL$1
16 - SEL$19EEE7EA / LOC@SEL$1
17 - SEL$19EEE7EA / ORD@SEL$1
18 - SEL$19EEE7EA / ORD@SEL$1
19 - SEL$639F1A6F / P@SEL$1
20 - SEL$639F1A6F
24 - SEL$639F1A6F / P@SEL$2
25 - SEL$639F1A6F / P@SEL$2
26 - SEL$639F1A6F / LOC@SEL$2
27 - SEL$639F1A6F / LOC@SEL$2
28 - SEL$639F1A6F / PFM@SEL$2
29 - SEL$639F1A6F / FAM@SEL$2
30 - SEL$639F1A6F / FAD@SEL$2
31 - SEL$19EEE7EA / F@SEL$1
32 - SEL$19EEE7EA / LOCT@SEL$1
33 - SEL$5
34 - SEL$5 / INTERFACE_ADT_AOE_MASTER@SEL$5
35 - SEL$5 / INTERFACE_ADT_AOE_MASTER@SEL$5
36 - SEL$6 / TEST@SEL$6
37 - SEL$6 / TEST@SEL$6
38 - SEL$7 / LAB_ORDER_OCC_TEST_AOE@SEL$7
39 - SEL$8
41 - SEL$8 / EMR_ADTAOE_DTL@SEL$8
42 - SEL$8 / EMR_ADTAOE_DTL@SEL$8
43 - SEL$9 / LAB_ORDER_OCC_TEST_AOE@SEL$9
Predicate Information (identified by operation id):
1 - filter( (SELECT /*+ */ COUNT(*) FROM "KORUS2XPROD_OWN"."INTERFACE_ADT_AOE_MASTER"
"INTERFACE_ADT_AOE_MASTER" WHERE "TEST_CODE"= (SELECT /*+ */ "TEST_CODE" FROM "KORUS2XPROD_OWN"."TEST" "TEST"
WHERE "TEST_ID"= (SELECT /*+ */ "AOE_TEST_ID" FROM "KORUS2XPROD_OWN"."LAB_ORDER_OCC_TEST_AOE"
"LAB_ORDER_OCC_TEST_AOE" WHERE "LAB_ORDER_OCC_TEST_ID"=:B1)) AND "SOURCE_SYSTEM"=:B2)<> (SELECT /*+ */ COUNT(*)
FROM "KORUS2XPROD_OWN"."EMR_ADTAOE_DTL" "EMR_ADTAOE_DTL" WHERE "TEST_ID"= (SELECT /*+ */ "AOE_TEST_ID" FROM
"KORUS2XPROD_OWN"."LAB_ORDER_OCC_TEST_AOE" "LAB_ORDER_OCC_TEST_AOE" WHERE "LAB_ORDER_OCC_TEST_ID"=:B3) AND
"PATIENT_ID"=:B4 AND "FACILITY_ID"=:B5 AND "STATUS"='Y' AND (TO_CHAR(TRUNC(INTERNAL_FUNCTION("DRAW_DATE"))) LIKE
TO_CHAR(TRUNC(:B6)) OR TRUNC(INTERNAL_FUNCTION("DRAW_DATE"))=TO_DATE(' 2999-12-31 00:00:00', 'syyyy-mm-dd
hh24:mi:ss')) AND "ANSWER" IS NOT NULL))
2 - access("LOCT"."TEST_ID"="$nso_col_1")
4 - filter(TRUNC(SYSDATE@!)-7<=TRUNC(SYSDATE@!))
7 - access("REQUIRED_TEST_CODE"="TEST_CODE")
8 - filter("LOCT"."STATUS"<>'R')
10 - access("F"."CORPORATION_ID"="C"."CORPORATION_ID")
12 - access("LOC"."FACILITY_ID"="F"."FACILITY_ID")
14 - access("ORD"."PATIENT_ID"="LOC"."PATIENT_ID" AND "ORD"."FACILITY_ID"="LOC"."FACILITY_ID" AND
"ORD"."DRAW_DT"="LOC"."ORDER_DRAW_DT")
15 - filter("LOC"."PATIENT_ID" IS NOT NULL AND "LOC"."MSG_SENT_TO_LAB_YN"='Y')
16 - access("LOC"."ORDER_DRAW_DT">=TRUNC(SYSDATE@!)-7 AND "LOC"."STATUS"='A' AND
"LOC"."ORDER_DRAW_DT"<=TRUNC(SYSDATE@!))
filter("LOC"."STATUS"='A')
17 - filter("ORD"."PATIENT_ID" IS NOT NULL)
18 - access("ORD"."DRAW_DT">=TRUNC(SYSDATE@!)-7 AND "ORD"."DRAW_DT"<=TRUNC(SYSDATE@!))
filter("ORD"."DRAW_DT">=TRUNC(SYSDATE@!)-7 AND "ORD"."DRAW_DT"<=TRUNC(SYSDATE@!))
20 - access("FAM"."FACILITY_ACCOUNT_DETAIL_ID"="FAD"."FACILITY_ACCOUNT_DETAIL_ID")
21 - access("PFM"."FACILITY_ACCOUNT_MODALITY_ID"="FAM"."FACILITY_ACCOUNT_MODALITY_ID")
22 - access("PFM"."FACILITY_ID"="LOC"."FACILITY_ID")
25 - access("P"."PATIENT_ID"="LOC"."PATIENT_ID")
27 - access("LOC"."PATIENT_ID"="LOC"."PATIENT_ID") -
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 Experts,
while running SQL Query i am getting an error as
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
T2.LineText
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,T2.LineText
how to resolve the issueDear Meghanath,
Please use the following query, Hope your purpose will serve.
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
CAST(T2.LineText as nvarchar (MAX))[LineText]
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry --where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,CAST(T2.LineText as nvarchar (MAX))
Regards,
Amit -
The link to system requirements for Firefox 4 beta takes you to a page that gives you the requirements for Firefox 3.6 instead. I assume that the requirements for the beta are different as I can't seem to install the beta on my Macs. Where can I find the beta system requirements?
I never expected Mozilla to neglect the users of Apple's PowerPC (PPC) computers, while still supporting much older operating environments such as Windows XP. So, I should just throw away a $6,000 system, which is still fast and functional, and contribute masses of heavy metals to land-fills because…?
I'm hurt and confused after supporting Firefox for many years — installing and using it not only on my own computers but on most of my customers' computers. Now I have to tell my customers with PPC Macs they can't have a secure cross-platform browsing experience from Mozilla. They'll have to learn to use some other browser, or buy a new computer.
If one doesn't buy a new computer every year, one doesn't deserve Firefox 4. This is sort of sounding more like a Microsoft™© doctrine. (But wait, I can still have Firefox 4 on a ''SERIOUSLY CRAPPY WINDBLOWS XP pile of rubbish?!'') Please open your eyes Mozilla. This just doesn't make sense. -
When `ve downloaded the latest itunes and then i go to install it i get a message saying there is a problem with this windows installer package a program required for the install to complete could not be run, contact your support personnal or package vendor any ideas anyone ? thanks
Try the following user tip:
"There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows -
Hi All,
What are the ports required for the Audio, Video and A/V conferencing when the following clients are enabled for QoS in Lync 2013 server?
Client Type
Port range and Protocol required for Audio
Port range and Protocol required for
Video
Port range and Protocol required for
A/Vconferencing
Windows Desktop Client
Windows mobile App
Iphone
Ipad
Andriod phone
Andriod Tablet
MAC desktop client
Please advise. Many Thanks.Out of the box, 1024-65535 for all of the client ports. :)
https://technet.microsoft.com/en-us/library/gg398833.aspx
You'll want to tune your client ports a bit
https://technet.microsoft.com/en-us/library/jj204760.aspx as seen here, and then the client ports would use those ranges which is easier to set QoS markings. I'm not sure the mobile clients respect that setting.
Elan's got the best writeup for Windows clients here:
http://www.shudnow.net/2013/02/16/enabling-qos-for-lync-server-2013-and-various-clients-part-1/
However, the marking of the packets is the tricky part. Windows can do it via Group Policy, but for the other clients you'll need to have the network specifically prioritize ports regardless of DSCP markings. You have to do it based on ports
as the traffic could be peer to peer.
Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer".
SWC Unified Communications
This forum post is based upon my personal experience and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
I want to upgrade my 2008 Mac pro to the latest one, will it meet the requirement for the future Software that's coming out for the next four years?.
I'd wait. What can't you do that you need? You mean you want to buy a new model, then why not wait for an actual new one, not the two year old 5,1, when you need to and have outgrown.
Yours will run Mountain Lion. yours is 4 yrs old and still supported and has life left. -
I am trying to download a free trial of photoshop for my macbook pro and it says there is an error and that the requirements for the new version is not supported for the mac I have. I have looked at the list of requirements but have no idea how to tell what I do and do not have?
Apple Menu --> About this Mac.
Mylenium -
I'm trying to download the trial version of Adobe Illustrator. An error message says that the OS does not meet the minimum system requirements for the installer. 10.6.0 is the minimum required for installation. How do I get my mac to be a 10.6.0 ? Right now I have a 10.5.8 is there a way to upgrade or something?
Buy the Snow Leopard retail installer (http://store.apple.com/us/product/MC573Z/A?fnode=MTY1NDAzOA).
That will take you to 10.6.3.
If required you can then use the combo updater to get to the latest version, 10.6.8 (http://support.apple.com/kb/DL1399)
SL system reqmts; -
Save Query - An error occurred while creating connection strings for the query
A workbook trying to edit and reload I get the following error "Save Query - An error occurred while creating connection strings for the query" No Power Pivot data model or anything.
I am getting the same error when editing a Power Query in an Excel spreadsheet. It happens when I change a Group By step to do a Sum instead of Count Rows.
-
When trying to load music from ITunes to my ipod I receive the error "The software required for the ipod is not installed correctly. Please reinstall itunes to install the required sotware"
What should I do to correct the error?For general advice see Troubleshooting issues with iTunes for Windows updates.
The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies. The notes below the box include tips on removing troublesome components.
The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
Your library should be unaffected by these steps but there also links to backup and recovery advice should it be needed.
tt2 -
RPD - Cannot obtain number of columns for the query result :Working with MS SQL 2012 schema
Hi All,
I have created my warehouse in MS SQL 2012.
For management purpose, I have created different schemas in SQL database
In RPD, Physical layer, when i view data > I get error as
[nQSError:16002] Cannot obtain number of columns for the query result.
[nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid object name 'tbl'..
[nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Statements could not be prepared..
I have already browsed : OBIEE 11g Strange ODBC Driver Error with SQL Server : Total Business Intelligence ... did not help me
please help!!!Hi All,
After all R&D it is been found that Oracle business administrator( RPD) needs default dbo schema. It doesn't accept custom schema for pulling data.
If anybody have other views please share.!!
Thank you -
Requirements for the Interactive Graph -- Process Monitoring in WLI
Hi,
In my WLI console I m not able to bring the Graphical View for the Process Monitoring. My server is running on HP-UX -11, however I am able to view the graph from the workshop (windows desktop). Is there any server side requirement for the Graphical view?You have to run xvfb (X Window virtual frame buffer) on the HP-UX box. You have to download that from HP's website. Run it using root user only. Set the DISPLAY of your admin server to the xvfb and then you will be able to see the graphical view.
-
To know the users and the variables for the query
Hi,
Say I have one query and which is executed 5 times in the day n i can see this in ST03N Expert mode. Now, suppose i want to see the users who executed the query and what are the selections they gave for the query to run, is there a place to see this?
Appreciate your time
SriramSriram,
You can use BW Statistics to view technical information regarding users. SAP also delivers queries that give you usage by users, just install from business content. The statistics cubes extract data from various tables including:
RSDDSTAT
RSDDSTATAGGR
etc..
You can search more, names will start with "RSDDSTAT*"
Hope it helps,
Farhan
Maybe you are looking for
-
Hi, All, Is there any way to know how many open purchase order quantity in the SAP system? If I want to differentiate different business unit open purchase order, how I can do? What's the T-code? Thanks
-
Yellow tinted screen my iPhone 4s is not jail token any fix?
Ugly yellow screen tint
-
i keep getting this error code 7 (windows error 126). can't open itunes, what do i do?
-
Safari 4 do not open new window
I was trying to access a bank web page, and at the moment I log in it supposed to open a new window with the links for the statements, on line transfer, etc, etc, however Safari 4 ask if the new page should be open only the first time (that time all
-
Copy/paste full row, full column, a cell on datagrid using MVVM?
What is the best way to implement on datagrid? As I am new on this, I had some researches but I am confused because there are some complicated implementations and easy ones? I try to understand the best way. Adding simply selection mode and selection