How to do this SQL installation in Yosemite?
I want SQL for learning purposes and my school use. Can anyone please help.
Install Windows using either Boot Camp or a virtual machine like Parallels, Fusion, or VirtualBox. Then install SQL Server and any other Windows programs you need.
Similar Messages
-
How to execute this SQL Query in ABAP Program.
Hi,
I have a string which is the SQL Query.
How to execute this sql Query (SQL_STR) in ABAP Program.
Code:-
DATA: SQL_STR type string.
SQL_STR = 'select * from spfli.'.
Thanks in Advance,
VinayHi Vinay
Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
REPORT dynamic_sql_example .
DATA: BEGIN OF gt_itab OCCURS 1 ,
line(80) TYPE c ,
END OF gt_itab .
DATA gt_restab TYPE .... .
DATA gv_name(30) TYPE c .
DATA gv_err(120) TYPE c .
START-OF-SELECTION .
gt_itab-line = 'REPORT generated_sql .' .
APPEND gt_itab .
gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
APPEND gt_itab .
gt_itab-line = SQL_STR .
APPEND gt_itab .
gt_itab-line = 'ENDFORM.' .
APPEND gt_itab .
GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
IF FOUND .
WRITE:/ gv_err .
LOOP AT gt_result .
WRITE:/ .... .
ENDLOOP .
*--Serdar -
Need help on how to code this SQL statement! (one key has leading zeros)
Good day, everyone!
First of all, I apologize if this isn't the best forum. I thought of putting it in the SAP Oracle database forum, but the messages there seemed to be geared outside of ABAP SELECTs and programming. Here's my question:
I would like to join the tables FMIFIIT and AUFK. The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
The problem I'm having is this: All of the values in AUFNR are preceeded by two zeros. For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'. Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
Unfortunately, I don't have a lot of experience coding SQL, so I'm not sure how to resolve this.
Please help! As always, I will award points to ALL helpful responses!
Thanks!!
Dave>
Dave Packard wrote:
> Good day, everyone!
> I would like to join the tables FMIFIIT and AUFK. The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
>
> The problem I'm having is this: All of the values in AUFNR are preceeded by two zeros. For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'. Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
> Dave
You can't do a join like this in SAP's open SQL. You could do it in real SQL ie EXEC.... ENDEXEC by using SUSBTR to strip off the leading zeros from AUFNR but this would not be a good idea because a) modifying a column in the WHERE clause will stop any index on that column being used and b) using real SQL rather than open SQL is really not something that should be encouraged for database portability reasons etc.
Forget about a database join and do it in two stages; get your AUFK data into an itab, strip off the leading zeros, and then use FAE to get the FMIFIIT data (or do it the other way round).
I do hope you've got an index on your FMIFIIT MEASURE field (we don't have one here); otherwise your SELECT could be slow if the table holds a lot of data. -
How to write this sql query in php code ?
for example:
insert into temp
select *
from testtable;
after this, i will query data from sql below:
select *
from temp;
how to write this php code ?
who can help me ?
thanks!Have a look at the manual to find out how to issue queries.
http://us3.php.net/oci8 -
What this SQL did is to generate a report like how many rows for each tp_stts when ims_toms_msge_type='TOMS NEW' (or 'TOMS CNCLO'). also, its corresponding total number for each ims_toms_msge_type.
Here is the sample:
Rownum H1 TP_STTS COUNT IMS_TOMS_MSGE_TYPE H FILTERTYPE
1 Trades Block Key Data Error 594 TOMS NEW A MSL
2 Allocation Data Error 334 TOMS NEW A MSL
3 Manual Processing Required 29 TOMS NEW A MSL
4 Manual Removal No Processing Required 67 TOMS NEW A MSL
5 Waiting For Authorization 2 TOMS NEW A MSL
6 Auto NAK 19764 TOMS NEW B SLS
7 Validated 165023 TOMS NEW B SLS
8 GRAND TOTAL 185813 TOMS NEW H MSL
9 Cancel Auto NAK 37 TOMS CNCLO X MSL
10 Manual Processing Required 114 TOMS CNCLO X MSL
11 Manually Processed 278 TOMS CNCLO X MSL
12 CANCEL GRAND TOTAL 429 TOMS CNCLO Z MSLSQL statement as below:
SELECT ROWNUM, MSGS.* FROM (with FTMReport as (
select tp_stts, ims_toms_msge_type, count(*) count from ims_trde, ims_toms_msge
where ( IMS_TRDE.PRCSG_GRP_ID = 5 ) AND ( IMS_TRDE.IMS_TRDE_RCPT_DTTM >= TO_DATE('12/01/2009 00:00', 'MM/DD/YYYY HH24:MI') AND IMS_TRDE.IMS_TRDE_RCPT_DTTM <= (TO_DATE('12/28/2009 23:59', 'MM/DD/YYYY HH24:MI')) ) AND (IMS_TRDE.GRS_TRX_TYPE NOT IN ('INJECTION','WITHDRAWAL','PAYMENT') OR IMS_TRDE.GRS_TRX_TYPE IS NULL) AND (IMS_TRDE.SSC_INVST_TYPE != 'FC' OR IMS_TRDE.SSC_INVST_TYPE IS NULL) AND (IMS_TRDE.SERVICE_TYPE='FS' OR IMS_TRDE.SERVICE_TYPE='CO') AND 1=1
and IMS_TRDE.SERVICE_TYPE='FS' and 1=1 and ims_trde.ims_trde_oid = ims_toms_msge.ims_trde_oid
group by tp_stts, ims_toms_msge_type
select 'GRAND TOTAL' H1, null tp_stts, sum(Count) count , ims_toms_msge_type ,'H', 'MSL' FilterType
from FTMReport where ims_toms_msge_type in ('TOMS NEW') group by ims_toms_msge_type
union
select 'CANCEL GRAND TOTAL' H1, null tp_stts, sum(Count) count, ims_toms_msge_type ,'Z', 'MSL' FilterType
from FTMReport where ims_toms_msge_type in ('TOMS CNCLO') group by ims_toms_msge_type
union
select DECODE(rownum, 1, 'Trades') H1, tp_stts, count, ims_toms_msge_type , 'A' , 'MSL' FilterType
from FTMReport where ims_toms_msge_type in ('TOMS NEW') and tp_stts not in ('Validated','Auto NAK','Manual NAK')
union
select ' ' H1, tp_stts, count, ims_toms_msge_type , 'B' , 'SLS' FilterType
from FTMReport where ims_toms_msge_type in ('TOMS NEW') and tp_stts in ('Validated','Auto NAK','Manual NAK')
union
select DECODE(rownum, 1, 'Cancel') H1, tp_stts, count, ims_toms_msge_type , 'X' , 'MSL' FilterType
from FTMReport where ims_toms_msge_type in ('TOMS CNCLO') order by 5,6
) MSGS;Explain plan as below:
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 193 | 12738 | 32 |
| 1 | COUNT | | | | |
| 2 | VIEW | | 193 | 12738 | 32 |
| 4 | TEMP TABLE TRANSFORMATION | | | | |
| 3 | RECURSIVE EXECUTION | SYS_LE_4_0 | | | |
| 0 | INSERT STATEMENT | | 61 | 4575 | 9264 |
| 1 | LOAD AS SELECT | | | | |
| 2 | SORT GROUP BY | | 61 | 4575 | 9264 |
| 3 | NESTED LOOPS | | 1604 | 117K| 9251 |
|* 4 | TABLE ACCESS BY INDEX ROWID| IMS_TRDE | 1603 | 80150 | 6045 |
|* 5 | INDEX RANGE SCAN | IMS_TRDE_INDX4 | 539K| | 3917 |
|* 6 | INDEX RANGE SCAN | IMS_TOMS_MSGE_INDX1 | 1 | 25 | 2 |
| 5 | SORT UNIQUE | | 193 | 8831 | 30 |
| 6 | UNION-ALL | | | | |
| 7 | SORT GROUP BY NOSORT | | 5 | 115 | 6 |
|* 8 | VIEW | | 61 | 1403 | 2 |
| 9 | TABLE ACCESS FULL | SYS_TEMP_0FD9D660F_B198D56F | 61 | 2074 | 2 |
| 10 | SORT GROUP BY NOSORT | | 5 | 115 | 6 |
|* 11 | VIEW | | 61 | 1403 | 2 |
| 12 | TABLE ACCESS FULL | SYS_TEMP_0FD9D660F_B198D56F | 61 | 2074 | 2 |
| 13 | COUNT | | | | |
|* 14 | VIEW | | 61 | 2867 | 2 |
| 15 | TABLE ACCESS FULL | SYS_TEMP_0FD9D660F_B198D56F | 61 | 2074 | 2 |
|* 16 | VIEW | | 61 | 2867 | 2 |
| 17 | TABLE ACCESS FULL | SYS_TEMP_0FD9D660F_B198D56F | 61 | 2074 | 2 |
| 18 | COUNT | | | | |
|* 19 | VIEW | | 61 | 2867 | 2 |
| 20 | TABLE ACCESS FULL | SYS_TEMP_0FD9D660F_B198D56F | 61 | 2074 | 2 |
Predicate Information (identified by operation id):
4 - filter(("IMS_TRDE"."GRS_TRX_TYPE"<>'INJECTION' AND "IMS_TRDE"."GRS_TRX_TYPE"<>'WITHDRAWAL'
AND "IMS_TRDE"."GRS_TRX_TYPE"<>'PAYMENT' OR "IMS_TRDE"."GRS_TRX_TYPE" IS NULL) AND
("IMS_TRDE"."SSC_INVST_TYPE"<>'FC' OR "IMS_TRDE"."SSC_INVST_TYPE" IS NULL))
5 - access("IMS_TRDE"."IMS_TRDE_RCPT_DTTM">=TO_DATE(' 2009-12-01 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AND "IMS_TRDE"."PRCSG_GRP_ID"=5 AND "IMS_TRDE"."SERVICE_TYPE"='FS' AND
"IMS_TRDE"."IMS_TRDE_RCPT_DTTM"<=TO_DATE(' 2009-12-28 23:59:00', 'syyyy-mm-dd hh24:mi:ss'))
filter("IMS_TRDE"."PRCSG_GRP_ID"=5 AND "IMS_TRDE"."SERVICE_TYPE"='FS')
6 - access("IMS_TRDE"."IMS_TRDE_OID"="IMS_TOMS_MSGE"."IMS_TRDE_OID")
8 - filter("FTMREPORT"."IMS_TOMS_MSGE_TYPE"='TOMS NEW')
11 - filter("FTMREPORT"."IMS_TOMS_MSGE_TYPE"='TOMS CNCLO')
14 - filter("FTMREPORT"."IMS_TOMS_MSGE_TYPE"='TOMS NEW' AND "FTMREPORT"."TP_STTS"<>'Validated'
AND "FTMREPORT"."TP_STTS"<>'Auto NAK' AND "FTMREPORT"."TP_STTS"<>'Manual NAK')
16 - filter("FTMREPORT"."IMS_TOMS_MSGE_TYPE"='TOMS NEW' AND ("FTMREPORT"."TP_STTS"='Auto NAK' OR
"FTMREPORT"."TP_STTS"='Manual NAK' OR "FTMREPORT"."TP_STTS"='Validated'))
19 - filter("FTMREPORT"."IMS_TOMS_MSGE_TYPE"='TOMS CNCLO')
Note: cpu costing is offCould you guys tell me what is wrong with this sql and how to tune it?
Is there any way to replace the UNION? Is using UNION a good idea?
Can I use DECODE or CASE WHEN to simplify it? How?
Also, could you help explain why there is SYS_LE_4_0, SYS_TEMP_0FD9D660F_B198D56F temporary segment? Is it caused by with FTMReport as ?
Thanks
Edited by: PhoenixBai on Dec 31, 2009 9:58 AM
Edited by: PhoenixBai on Dec 31, 2009 12:08 PM
Edited by: PhoenixBai on Dec 31, 2009 12:17 PMI consider using GROUP BY ROLLUP together with DECODE, CASE WHEN, but haven`t come out with a working sql yet:-(Some sample data to work with would have been much helpful. But we dont get that most of the time :(
I came up with this.
select case when ims_toms_msge_type = 'TOMS NEW' then
case when grouping(tp_stts) = 1 then 'GRAND TOTAL'
when tp_stts not in ('Validated','Auto NAK','Manual NAK') then 'Trades'
end
when ims_toms_msge_type = 'TOMS CNCLO' then
case when grouping(tp_stts) = 1 then 'CANCEL GRAND TOTAL'
when tp_stts in ('Validated','Auto NAK','Manual NAK') then 'Cancel'
end
end h1,
tp_stts,
count(*) count,
ims_toms_msge_type,
case when ims_toms_msge_type = 'TOMS NEW' then
case when grouping(tp_stts) = 1 then 'H'
when tp_stts not in ('Validated','Auto NAK','Manual NAK') then 'A'
end
when ims_toms_msge_type = 'TOMS CNCLO' then
case when grouping(tp_stts) = 1 then 'Z'
when tp_stts in ('Validated','Auto NAK','Manual NAK') then 'B'
end
end flag,
'MSL' FilterType
from ims_trde,
ims_toms_msge
where IMS_TRDE.PRCSG_GRP_ID = 5
AND IMS_TRDE.IMS_TRDE_RCPT_DTTM >= TO_DATE('12/01/2009 00:00', 'MM/DD/YYYY HH24:MI')
AND IMS_TRDE.IMS_TRDE_RCPT_DTTM <= TO_DATE('12/28/2009 23:59', 'MM/DD/YYYY HH24:MI')
AND (IMS_TRDE.GRS_TRX_TYPE NOT IN ('INJECTION','WITHDRAWAL','PAYMENT')
OR IMS_TRDE.GRS_TRX_TYPE IS NULL)
AND (IMS_TRDE.SSC_INVST_TYPE != 'FC'
OR IMS_TRDE.SSC_INVST_TYPE IS NULL)
AND (IMS_TRDE.SERVICE_TYPE = 'FS'
OR IMS_TRDE.SERVICE_TYPE = 'CO')
AND 1=1
and IMS_TRDE.SERVICE_TYPE = 'FS'
and 1=1
and ims_trde.ims_trde_oid = ims_toms_msge.ims_trde_oid
group by rollup(ims_toms_msge_type, tp_stts)Not sure if this code works. Because i dint have the table or the data to test it. So if it has some error just fix it and give it a try. Do post the kind of output it gives. So that we can see if we can work with this solution. -
How to optimize this SQL. Help needed.
Hi All,
Can you please help with this SQL:
SELECT /*+ INDEX(zl1 zipcode_lat1) */
zl2.zipcode as zipcode,l.location_id as location_id,
sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2)) as distance
FROM location_atao l, zipcode_atao zl1, client c, zipcode_atao zl2
WHERE zl1.zipcode = l.zipcode
AND l.client_id = c.client_id
AND c.client_id = 306363
And l.appType = 'HOURLY'
and c.milessearchzipcode >= sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2))
I tried to optimize it by adding country column in zipcode_atao table. So that we can limit the search in zipcode_atao table based on country.
Any other suggestions.
ThanksWelcome to the forum.
Please follow the instructions given in this thread:
How to post a SQL statement tuning request
HOW TO: Post a SQL statement tuning request - template posting
and add the nessecary details we need to your thread.
Depending on your database version (the result of: select * from v$version; ):
Have you tried running the query without the index-hint?
Are your table (and index) statatistics up-to-date? -
How to optimize this sql by writing MINUS function.
Hi all,
how to optimize the sql by writing MINUS function.
these are my tables
1. CREATE TABLE POSTPAID
RECORD VARCHAR2(2000 BYTE),
FLAG NUMBER
Record format:
Mobile no in 1:10 of that length
2. CREATE TABLE SUBSCRIBER
PHONE_NO VARCHAR2(10 BYTE)
My requirement is following sql need write using ‘minus’ as this one is very slow
select record record from POSTPAID where substr(record,9,10) NOT in (select PHONE_NO from SUBSCRIBER)
ThanksWhy are you very particular about using "MINUS". You can optimize the sql by using "NOT EXISTS" instead of "NOT IN" as below:
SELECT RECORD FROM POSTPAID A WHERE NOT EXISTS (SELECT 1 FROM SUBSCRIBER B WHERE SUBSTR(A.RECORD,9,10) = B.PHONE_NO) -
How to rewrite this SQL statement
I have tableA and tableB as below. The following query gets Max(Process_date) during month of january from the
two tables tableA and tableB with different criteria
I want to expand the following query to return Max(Process_date) for BOTH current month(txn_date=entire jan2013) and prior month(txn_date= entire dec2013)
Is it possible? If so how can I modify this query to return MAX(PROCESS_DATE) for current and prior months in single query.
SELECT MAX(process_date) AS curr_month_amount FROM
SELECT process_date AS process_date,
amount1 AS amount
FROM tableA
WHERE id = 1 AND
process_date = (SELECT MAX(process_date)
FROM tableA
WHERE id = 1 and txn_date between TO_DATE('01-JAN-2013','dd-mon-yyyy') and TO_DATE('31-JAN-2013', 'dd-mon-yyyy')
AND amount1 = 0
UNION
SELECT MAX(process_date) AS process_date,
0 AS amount
FROM tableB
WHERE id = 1 AND txn_code = 'B' and txn_date between TO_DATE('01-JAN-2013','dd-mon-yyyy') and TO_DATE('31-JAN-2013', 'dd-mon-yyyy')
future state of the sql
Single sql statement a) should look at txn_date between 1/1/2013 - 1/31/2013 to return max(process_date) for current month
b) should look at txn_date between 12/1/2012 - 12/31/2012 to return max(process_date) for prior month
NOTE:-( i want to pass current_month_end date 1/31/2013 to this sql so it will calculate for current and prior months)
expected output
***************: For id=1 in the modified query,
prior month max(process_date) should be 1/19/2013
current month max(process_date) should be 1/15/2012
For id=5 in the modified query
prior month max(process_date) should be NULL
current month max(process_date) should be 1/16/2013
SQL to create TableA and TableB with insert statements( txn_date column not included)
CREATE table tableA
id NUMBER,
process_date DATE,
amount1 NUMBER,
txn_code VARCHAR2(1),
txn_date DATE
Create table tableB
( id NUMBER,
process_date DATE,
amount2 NUMBER,
txn_code VARCHAR2(1),
txn_date DATE
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 1, to_date('01/12/2013','mm/dd/yyyy'), 500, 'A', to_date('01/15/2013','mm/dd/yyyy') );
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 1, to_date('01/13/2013','mm/dd/yyyy'), 100, 'A', to_date('01/14/2013','mm/dd/yyyy'));
INSERT INTO tableA
( id, process_date, amount1, txn_code , txn_date)
values
( 1, to_date('01/14/2013','mm/dd/yyyy'), 0, 'A', to_date('01/15/2013','mm/dd/yyyy'));
INSERT INTO tableB
( id, process_date, amount2, txn_code, txn_date)
values
( 1, to_date('01/15/2013','mm/dd/yyyy'), 0, 'B', to_date('01/31/2013','mm/dd/yyyy'));
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 1, to_date('12/01/2012','mm/dd/yyyy'), 500, 'A', to_date('12/31/2012','mm/dd/yyyy') );
INSERT INTO tableA
( id, process_date, amount1, txn_code , txn_date)
values
( 1, to_date('12/23/2012','mm/dd/yyyy'), 100, 'A', to_date('12/14/2012','mm/dd/yyyy'));
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 1, to_date('12/19/2012','mm/dd/yyyy'), 0, 'A', to_date('12/15/2012','mm/dd/yyyy'));
INSERT INTO tableB
( id, process_date, amount2, txn_code, txn_date)
values
( 1, to_date('12/15/2012','mm/dd/yyyy'), 0, 'C', to_date('12/31/2012','mm/dd/yyyy'));
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 5, to_date('01/11/2013','mm/dd/yyyy'), 500, 'A', to_date('01/09/2013','mm/dd/yyyy') );
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
(5, to_date('01/12/2013','mm/dd/yyyy'), 0, 'A', to_date('01/19/2013','mm/dd/yyyy'))
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 5, to_date('01/15/2013','mm/dd/yyyy'), 10 , 'A', to_date('01/09/2013','mm/dd/yyyy'));
INSERT INTO tableB
( id, process_date, amount2, txn_code, txn_date)
values
( 5, to_date('01/16/2013','mm/dd/yyyy'), 1, 'B', to_date('01/09/2013','mm/dd/yyyy'));
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 5, to_date('12/11/2012','mm/dd/yyyy'), 500, 'A', to_date('12/09/2012','mm/dd/yyyy') );
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
(5, to_date('12/12/2012','mm/dd/yyyy'), 0, 'A', to_date('12/19/2012','mm/dd/yyyy'))
INSERT INTO tableA
( id, process_date, amount1, txn_code, txn_date )
values
( 5, to_date('12/15/2012','mm/dd/yyyy'), 10 , 'A', to_date('12/09/2012','mm/dd/yyyy'));
INSERT INTO tableB
( id, process_date, amount2, txn_code, txn_date)
values
( 5, to_date('12/16/2012','mm/dd/yyyy'), 1, 'C', to_date('12/09/2012','mm/dd/yyyy'));
commit;Maybe
SELECT id,
month,
MAX(process_date) AS curr_month_amount
FROM (SELECT id,
process_date AS process_date,
amount1 AS amount,
TO_CHAR(txn_date,'mm') AS month
FROM tableA
WHERE (process_date,TO_CHAR(txn_date,'mm')) in
(SELECT MAX(process_date),TO_CHAR(txn_date,'mm')
FROM tableA
WHERE txn_date between ADD_MONTHS(TO_DATE('01-JAN-2013','dd-mon-yyyy'),-1)
AND TO_DATE('31-JAN-2013','dd-mon-yyyy')
AND amount1 = 0
GROUP BY TO_CHAR(txn_date,'mm')
AND amount1 = 0
UNION
SELECT id,
MAX(process_date) AS process_date,
0 AS amount,
TO_CHAR(txn_date,'mm') AS month
FROM tableB
WHERE txn_code = 'B'
AND txn_date between ADD_MONTHS(TO_DATE('01-JAN-2013','dd-mon-yyyy'),-1)
AND TO_DATE('31-JAN-2013','dd-mon-yyyy')
GROUP BY id,TO_CHAR(txn_date,'mm')
GROUP BY id,month
ID
MONTH
CURR_MONTH_AMOUNT
5
01
01/16/2013
1
12
12/19/2012
1
01
01/15/2013
Regards
Etbin -
This is the sql for tuning. The driving table all_dist_gl is about 2 bln records. This sql is run more than 40min. The result is about 5k rows.
Thanks for your any advice. I will be appreciate for your example.
--Region_code_list is a package to determain which region is.
select
rowidtochar(adlg.rowid) row_id,
adlg.cust_trx_line_gl_dist_id,
adlg.posting_control_id,
adlg.set_of_books_id,
adlg.org_id,
adlg.amount,
adlg.acctd_amount,
adlg.last_update_date,
adlg.customer_trx_line_id,
adlg.customer_trx_id,
adlg.cust_trx_line_salesrep_id,
adlg.gl_date,
adlg.gl_posted_date
from all_dist_gl adlg
where
adlg.account_class = 'REV'
and adlg.account_set_flag = 'N'
and (adlg.posting_control_id <> -3 or (adlg.posting_control_id = -3 and adlg.gl_date <= trunc(sysdate)))
and last_update_date between to_date('2004-12-31 11:59:59','YYYY-MM-DD HH24:MI:SS') and to_date('2009-07-07 12:47:24','YYYY-MM-DD HH24:MI:SS')
and region_code_list.by_organization('UK',adlg.org_id) = 1The database version is
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
Execution Plan
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 2786 | 236K| 141K (2)|
|* 1 | TABLE ACCESS BY INDEX ROWID| RA_CUST_TRX_LINE_GL_DIST_ALL | 2786 | 236K| 141K (2)|
|* 2 | INDEX RANGE SCAN | BCIRA_CUST_TRX_LINE_GL_DIST_N1 | 2785K| | 11830 (3)|
Predicate Information (identified by operation id):
1 - filter("CTLGD"."ACCOUNT_CLASS"='REV' AND "CTLGD"."ACCOUNT_SET_FLAG"='N' AND
"BCIEDW_REGION_CODE"."BY_ORGANIZATION"('FE',"CTLGD"."ORG_ID")=1 AND
("CTLGD"."POSTING_CONTROL_ID"<>(-3) OR "CTLGD"."POSTING_CONTROL_ID"=(-3) AND
"CTLGD"."GL_DATE"<=TRUNC(SYSDATE@!)))
2 - access("LAST_UPDATE_DATE">=TO_DATE(' 2009-04-25 12:20:13', 'syyyy-mm-dd
hh24:mi:ss') AND "LAST_UPDATE_DATE"<=TO_DATE(' 2009-06-26 12:47:24', 'syyyy-mm-dd
hh24:mi:ss'))
Note
- 'PLAN_TABLE' is old version
Statistics
59429 recursive calls
0 db block gets
169819 consistent gets
41652 physical reads
0 redo size
30476 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
38 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
555 rows processed
SQL> -
We have a table, the structure as below: (I put a blank row in the middle to make it clear)
Product_ID Retailer Retail_Price
1001 A 1.2
1001 B 1.5
1001 C 1.4
1002 B 2.0
1002 C 2.1
1002 E 1.8
1002 F 2.0
1003 A 1.7
1003 C 1.5
Basically we use the table to compare the retail price for different retailers in terms of different products. My customer asked me to give a report based on above table but only shows the retail prices which contain retailer A.
For example, on above table I need to give a report like below:
Product_ID Retailer Retail_Price
1001 A 1.2
1001 B 1.5
1001 C 1.4
1003 A 1.7
1003 C 1.5
Can anybody give some ideas on how I should write a SQL to achieve this.
Many thanks!SQL> create table product(
2 Product_ID varchar2(10),
3 Retailer varchar2(10),
4 Retail_Price number(7,2)
5 )
6 /
Table created.
SQL> insert into product values('1001','A',1.2)
2 /
1 row created.
SQL> insert into product values('1001','B',1.5)
2 /
1 row created.
SQL> insert into product values('1001','C',1.4)
2 /
1 row created.
SQL> insert into product values('1002','B',2.0)
2 /
1 row created.
SQL> insert into product values('1002','C',2.1)
2 /
1 row created.
SQL> insert into product values('1002','E',1.8)
2 /
1 row created.
SQL> insert into product values('1002','F',2.0)
2 /
1 row created.
SQL> insert into product values('1003','A',1.7)
2 /
1 row created.
SQL> insert into product values('1003','C',1.5)
2 /
1 row created.
SQL> select * from product
2 /
PRODUCT_ID RETAILER RETAIL_PRICE
1001 A 1.2
1001 B 1.5
1001 C 1.4
1002 B 2
1002 C 2.1
1002 E 1.8
1002 F 2
1003 A 1.7
1003 C 1.5
9 rows selected.
SQL> select * from product where PRODUCT_ID in (
2 select distinct PRODUCT_ID from product where RETAILER='A')
3 /
PRODUCT_ID RETAILER RETAIL_PRICE
1001 A 1.2
1001 B 1.5
1001 C 1.4
1003 A 1.7
1003 C 1.5 -
How to write this sql query to oracle
Hi sir,
i am using one query in my sql stored procedure that is:
select @maxtime=CONVERT(Time,Out_Time+DATEADD(n,60,0)) from shift where Shift_Code = @ShiftCode
so here i am getting this value 01/01/1900 12:00 AM
the same i used in oracle my query is :
to_char(Out_Time,'1900-01-01' + 0/(24*60),'DD/MM/YYYY HH:MI AM')
INTO v_maxtime
FROM shift
WHERE Shift_Code = v_ShiftCode;
but getting error that is: Encountered the symbol INTO when expecting one of the following :=(%;
am i doing any thing wrong.
thanksAPC wrote:
The error you're getting is a syntax error. In this case because you've mangled the TO_CHAR syntax. Alas I cannot give you the correct version because I cannot unpick what you're trying to do with that statement.
It would be easier if you expalined what business logic you're trying to implement instead of asking us to interpret a piece of shonky SQL.It's yet another of the OP's questions about how to do DATEs in Oracle (so many threads it can get very confusing - even though the OP has been asked to stick to one thread!).
The code looks like it's based on the answer I gave here:
How to get exact query of sql in oracle?
but clearly he doesn't understand the basic syntax of Oracle or the datatypes he's using. Sometimes you just have to give up... (I know I have) -
How to convert this SQL query to PL/SQL
I basically need to create an anonymous block that will display each student's first name, last name and the count of students who scored less on test 1 than the student.
So basically we need to find the count of students who have scored less than that particular student and we do it for all students in the table.
So for this particular query i designed my code in SQL
select g1.gr_fname, g1.gr_lname, count(*)
from grade g1, grade g2
where g1.gr_t1 > g2.gr_t1 and
g1.std_code = g2.std_code
group by g1.gr_fname, g1.gr_lname;
But i am unable to get the logic as to how to execute it in PL/SQL,I am missing something a minor detail to execute the same in PL/SQL
could someone please help me with the logic.
ThanksHi welcome to the forum try some thing below
SQL> DECLARE
2 CURSOR c1
3 IS
4 SELECT ename, sal, d.deptno
5 FROM scott.emp e, scott.dept d
6 WHERE e.deptno = d.deptno
7 GROUP BY ename, sal, d.deptno;
8 BEGIN
9 FOR c2 IN c1
10 LOOP
11 DBMS_OUTPUT.put_line ('name is ' || c2.ename);
12 END LOOP;
13 END;
14 /
name is CLARK
name is KING
name is JONES
name is MARTIN
name is FORD
name is SCOTT
name is ALLEN
name is TURNER
name is WARD
name is MILLER
name is ADAMS
name is BLAKE
name is JAMES
name is SMITH
PL/SQL procedure successfully completed.This is just to demonstrate the use of PL/SQL block -
How to write this sql code ?
for example below shows:
create table temp
order_type varchar2(30),
order_num number);
insert into temp values('apple',000001);
insert into temp values('banana',000002);
insert into temp values('chair',000003);
select *
from temp
where instr(order_type,decode(x,1,'a',2,'b',2,'c',order_type)) >0
if i let x equals 2 and i want to get b and c from above querying .
why above query could not get 'c' and only get 'b' if i give 2 to x ?
how to write above select clause ?
who can help me ?
thanks!Decode will return the first match;
SQL> select decode(2,1,'a',2,'b',2,'c')
from dual
D
b
1 row selected.This may help;
old: select *
from temp
where regexp_like(order_type, case to_number(&x)
when 1 then 'a'
when 2 then 'b|c'
end)
new: select *
from temp
where regexp_like(order_type, case to_number(2)
when 1 then 'a'
when 2 then 'b|c'
end)
ORDER_TYPE ORDER_NUM
banana 2
chair 3
2 rows selected. -
How to tune this SQL Query?
Hi all expert out there,
I am using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options.
I have this ERP 11i query took 3-4hours to execute. can anyone help to have a look at the Query so make it more faster? I am already out of my idea of solving this. Kindly helpzzz...
SELECT
/*+ first_rows(1)*/
hou.name "OU" ,-- e.g. Seagate Technology USOP1 ,
mc.description,
oel.ordered_item "Product Part Number",
oeh.order_number "Order Num",
hp.party_name "Bill To Cust Name",
hcsu.location "Ship To Cust Num",
oel.line_number || '.' || oel.shipment_number "Order Line Num",
ft.nls_territory "Ship To Country",
mc.segment7 "designapplication",
ccm.formattedcapacity||'GB' "Capacity",
oel.attribute1 "Order Category",
oel.Subinventory "Subinventory",
to_char(oel.actual_shipment_date,'MM/DD/YYYY DY') "Shipment Date",
NVL(oel.shipped_quantity,0) "Net Units"
FROM
oe_order_headers_all oeh
,oe_order_lines_all oel
,apps.hz_parties hp
,apps.hz_cust_accounts hca
,apps.hz_cust_site_uses_all hcsu
,apps.hz_cust_acct_sites_all hcas
, apps.seaeng_ccfamilymodelinfo ccm
,apps.hz_party_sites hps
,apps.fnd_territories ft
,apps.hz_locations hl
,apps.hr_organization_units hou
,apps.mtl_parameters mp
,apps.mtl_item_categories mic
,apps.mtl_categories_b mc
,apps.fnd_lookup_values flv
WHERE
oeh.header_id = oel.header_id
AND oel.flow_status_code = 'CLOSED'
AND oeh.invoice_to_org_id = hcsu.site_use_id
AND hl.country = ft.territory_code
AND hps.location_id = hl.location_id
AND hcas.party_site_id = hps.party_site_id
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
AND hcas.cust_account_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND oeh.org_id = hou.organization_id
AND oel.ship_from_org_id = mp.organization_id
AND oel.inventory_item_id = mic.inventory_item_id
AND mic.category_id = mc.category_id
AND mic.category_set_id = 4
AND mc.description = ccm.stmodelnumber
AND flv.lookup_code = hca.sales_channel_code
AND flv.lookup_type = 'SALES_CHANNEL'
AND mc.segment7 IN ('PSG','ESG','NSG')
AND flv.lookup_code NOT IN ('RTL','AD-RTL','EU')
AND oel.attribute1 IN ('NB','NBEOL','NBSEA')
AND oel.subinventory IN ('KFGI','AFGI','SFGIF','FGIF')
AND hou.organization_id = 189
AND trunc(oel.actual_shipment_date) between TO_DATE('01-Jan-2009','DD-MON-YYYY') and TO_DATE('31-JAN-2009','DD-MON-YYYY')
regards,
Lygine
Edited by: user8989062 on Jun 7, 2010 6:39 PM5) The TKPROF output for this statement looks like the following:
SELECT
/*+ first_rows(1)*/
hou.name "OU" ,-- e.g. Seagate Technology USOP1 ,
mc.description,
oel.ordered_item "Product Part Number",
oeh.order_number "Order Num",
hp.party_name "Bill To Cust Name",
hcsu.location "Ship To Cust Num",
oel.line_number || '.' || oel.shipment_number "Order Line Num",
ft.nls_territory "Ship To Country",
mc.segment7 "designapplication",
ccm.formattedcapacity||'GB' "Capacity",
oel.attribute1 "Order Category",
oel.Subinventory "Subinventory",
to_char(oel.actual_shipment_date,'MM/DD/YYYY DY') "Shipment Date",
NVL(oel.shipped_quantity,0) "Net Units"
FROM
oe_order_headers_all oeh
,oe_order_lines_all oel
,apps.hz_parties hp
,apps.hz_cust_accounts hca
,apps.hz_cust_site_uses_all hcsu
,apps.hz_cust_acct_sites_all hcas
, apps.seaeng_ccfamilymodelinfo ccm
,apps.hz_party_sites hps
,apps.fnd_territories ft
,apps.hz_locations hl
,apps.hr_organization_units hou
,apps.mtl_parameters mp
,apps.mtl_item_categories mic
,apps.mtl_categories_b mc
,apps.fnd_lookup_values flv
WHERE
oeh.header_id = oel.header_id
AND oel.flow_status_code = 'CLOSED'
AND oeh.invoice_to_org_id = hcsu.site_use_id
AND hl.country = ft.territory_code
AND hps.location_id = hl.location_id
AND hcas.party_site_id = hps.party_site_id
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
AND hcas.cust_account_id = hca.cust_account_id
AND hca.party_id = hp.party_id
AND oeh.org_id = hou.organization_id
AND oel.ship_from_org_id = mp.organization_id
AND oel.inventory_item_id = mic.inventory_item_id
AND mic.category_id = mc.category_id
AND mic.category_set_id = 4
AND mc.description = ccm.stmodelnumber
AND flv.lookup_code = hca.sales_channel_code
AND flv.lookup_type = 'SALES_CHANNEL'
AND mc.segment7 IN ('PSG','ESG','NSG')
AND flv.lookup_code NOT IN ('RTL','AD-RTL','EU')
AND oel.attribute1 IN ('NB','NBEOL','NBSEA')
AND oel.subinventory IN ('KFGI','AFGI','SFGIF','FGIF')
AND hou.organization_id = 189
AND trunc(oel.actual_shipment_date) between TO_DATE('01-Jan-2009','DD-MON-YYYY') and TO_DATE('31-JAN-2009','DD-MON-YYYY')
call count cpu elapsed disk query current rows
Parse 1 0.79 0.79 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 7 22.23 240.85 19781 536082 0 592
total 9 23.02 241.64 19781 536082 0 592
Misses in library cache during parse: 1
Optimizer mode: FIRST_ROWS
Parsing user id: 173
Rows Row Source Operation
592 NESTED LOOPS (cr=536082 pr=19781 pw=0 time=240822989 us)
592 NESTED LOOPS (cr=534885 pr=19776 pw=0 time=239960969 us)
592 NESTED LOOPS (cr=533688 pr=19776 pw=0 time=239902332 us)
594 NESTED LOOPS (cr=532493 pr=19776 pw=0 time=239811721 us)
594 NESTED LOOPS (cr=531892 pr=19776 pw=0 time=239794703 us)
594 NESTED LOOPS (cr=530693 pr=19772 pw=0 time=239325284 us)
594 NESTED LOOPS (cr=529498 pr=19770 pw=0 time=239152940 us)
594 NESTED LOOPS (cr=527709 pr=19766 pw=0 time=236850676 us)
594 NESTED LOOPS (cr=525920 pr=19764 pw=0 time=235640068 us)
2990 NESTED LOOPS (cr=516943 pr=19688 pw=0 time=195144282 us)
2990 NESTED LOOPS (cr=516936 pr=19688 pw=0 time=195120297 us)
2990 NESTED LOOPS (cr=510806 pr=19682 pw=0 time=194678671 us)
3000 HASH JOIN (cr=504799 pr=19669 pw=0 time=193829763 us)
3000 NESTED LOOPS (cr=472280 pr=360 pw=0 time=49218087 us)
1 NESTED LOOPS (cr=1029 pr=34 pw=0 time=1745829 us)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS_TL (cr=424 pr=25 pw=0 time=1361442 us)
1 INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=423 pr=25 pw=0 time=1361397 us)(object id 44637)
1 TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=605 pr=9 pw=0 time=384370 us)
1 INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=1 pr=0 pw=0 time=27 us)(object id 43498)
3000 TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=471251 pr=326 pw=0 time=47466249 us)
156922 INDEX RANGE SCAN OE_ORDER_LINES_N20 (cr=420 pr=7 pw=0 time=787919 us)(object id 37005064)
263469 TABLE ACCESS FULL MTL_ITEM_CATEGORIES (cr=32519 pr=19309 pw=0 time=144242743 us)
2990 TABLE ACCESS BY INDEX ROWID MTL_CATEGORIES_B (cr=6007 pr=13 pw=0 time=843569 us)
3000 INDEX UNIQUE SCAN MTL_CATEGORIES_B_U1 (cr=3007 pr=2 pw=0 time=162636 us)(object id 37199)
2990 TABLE ACCESS BY INDEX ROWID SEAENG_CCFAMILYMODELINFO (cr=6130 pr=6 pw=0 time=437784 us)
2990 INDEX UNIQUE SCAN SEAENG_CCFAMILYMODELINFO_U1 (cr=2997 pr=0 pw=0 time=52872 us)(object id 35838918)
2990 INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=7 pr=0 pw=0 time=16332 us)(object id 37657)
594 TABLE ACCESS BY INDEX ROWID OE_ORDER_HEADERS_ALL (cr=8977 pr=76 pw=0 time=40491633 us)
2990 INDEX UNIQUE SCAN OE_ORDER_HEADERS_U1 (cr=5987 pr=45 pw=0 time=2504442 us)(object id 41952)
594 TABLE ACCESS BY INDEX ROWID HZ_CUST_SITE_USES_ALL (cr=1789 pr=2 pw=0 time=1208576 us)
594 INDEX UNIQUE SCAN HZ_CUST_SITE_USES_U1 (cr=1195 pr=1 pw=0 time=105934 us)(object id 25124976)
594 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCT_SITES_ALL (cr=1789 pr=4 pw=0 time=2300224 us)
594 INDEX UNIQUE SCAN HZ_CUST_ACCT_SITES_U1 (cr=1195 pr=2 pw=0 time=152238 us)(object id 25124996)
594 TABLE ACCESS BY INDEX ROWID HZ_PARTY_SITES (cr=1195 pr=2 pw=0 time=170875 us)
594 INDEX UNIQUE SCAN HZ_PARTY_SITES_U1 (cr=601 pr=1 pw=0 time=104550 us)(object id 25124993)
594 TABLE ACCESS BY INDEX ROWID HZ_LOCATIONS (cr=1199 pr=4 pw=0 time=467329 us)
594 INDEX UNIQUE SCAN HZ_LOCATIONS_U1 (cr=601 pr=0 pw=0 time=57749 us)(object id 25124992)
594 TABLE ACCESS BY INDEX ROWID FND_TERRITORIES (cr=601 pr=0 pw=0 time=15562 us)
594 INDEX UNIQUE SCAN FND_TERRITORIES_U1 (cr=7 pr=0 pw=0 time=6492 us)(object id 33083)
592 TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=1195 pr=0 pw=0 time=88925 us)
594 INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=601 pr=0 pw=0 time=27607 us)(object id 81600)
592 INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=1197 pr=0 pw=0 time=56714 us)(object id 32878)
592 TABLE ACCESS BY INDEX ROWID HZ_PARTIES (cr=1197 pr=5 pw=0 time=860140 us)
592 INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=599 pr=0 pw=0 time=51136 us)(object id 25126074)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 7 0.00 0.00
row cache lock 1 0.00 0.00
gc current block 2-way 24112 0.00 19.28
gc cr grant 2-way 406 0.00 0.19
db file sequential read 441 0.09 14.11
gc cr block 2-way 284 0.00 0.23
gc cr block busy 147 0.19 9.59
gc current block congested 2 0.00 0.00
gc cr multi block request 13079 0.00 3.98
SQL*Net message from client 7 0.27 1.87
gc cr failure 39 0.00 0.02
cr request retry 39 0.98 38.27
SQL*Net more data to client 12 0.00 0.00
db file scattered read 2446 0.13 132.58
gc cr disk read 5 0.00 0.00
********************************************************************************6) The DBMS_XPLAN.DISPLAY_CURSOR output:
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID b8pfhfxscqn1m, child number 0
SELECT /*+ gather_plan_statistics */ hou.name "OU" ,-- e.g. Seagate Technology USOP1 , mc.descript
oeh.order_number "Order Num", hp.party_name "Bill To Cust Name", hcsu.location "Ship To Cust Num",
Num", ft.nls_territory "Ship To Country", mc.segment7 "designapplication", ccm.formattedcapacity
oel.Subinventory "Subinventory", to_char(oel.actual_shipment_date,'MM/DD/YYYY DY') "Shipment Date",
oe_order_headers_all oeh ,oe_order_lines_all oel ,apps.hz_parties hp ,apps.hz_cust
,apps.hz_cust_acct_sites_all hcas , apps.seaeng_ccfamilymodelinfo ccm ,apps.hz_party_sites hps
,apps.hr_organization_units hou ,apps.mtl_paramete
Plan hash value: 414863479
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | O
| 1 | NESTED LOOPS | | 1 | 1 | 592 |00:02:25.13 | 535K| 57267 | |
| 2 | NESTED LOOPS | | 1 | 1 | 592 |00:02:24.22 | 533K| 57185 |
| 3 | NESTED LOOPS | | 1 | 1 | 592 |00:02:24.15 | 532K| 57183 |
| 4 | NESTED LOOPS | | 1 | 1 | 594 |00:02:24.00 | 531K| 57171 |
| 5 | NESTED LOOPS | | 1 | 1 | 594 |00:02:23.98 | 530K| 57170 |
| 6 | NESTED LOOPS | | 1 | 1 | 594 |00:02:23.49 | 529K| 57129 |
| 7 | NESTED LOOPS | | 1 | 1 | 594 |00:02:23.08 | 528K| 57096 |
| 8 | NESTED LOOPS | | 1 | 1 | 594 |00:02:22.51 | 526K| 57031 | |
| 9 | NESTED LOOPS | | 1 | 1 | 594 |00:02:21.79 | 524K| 56968 | |
| 10 | NESTED LOOPS | | 1 | 1 | 2990 |00:02:09.65 | 515K| 55703 |
| 11 | NESTED LOOPS | | 1 | 1 | 2990 |00:02:09.62 | 515K| 55703 |
| 12 | NESTED LOOPS | | 1 | 1 | 2990 |00:02:08.47 | 509K| 55599 |
|* 13 | HASH JOIN | | 1 | 2 | 3000 |00:02:07.88 | 503K| 55516 | 974K
| 14 | NESTED LOOPS | | 1 | 2 | 3000 |00:01:39.07 | 471K| 23025 |
| 15 | NESTED LOOPS | | 1 | 1 | 1 |00:00:00.01 | 4 | 0 |
| 16 | TABLE ACCESS BY INDEX ROWID| HR_ALL_ORGANIZATION_UNITS_TL | 1 | 1 | 1 |00:00
|* 17 | INDEX UNIQUE SCAN | HR_ALL_ORGANIZATION_UNTS_TL_PK | 1 | 1 | 1 |00:00:00.0
|* 18 | TABLE ACCESS BY INDEX ROWID| HR_ALL_ORGANIZATION_UNITS | 1 | 1 | 1 |00:00:
|* 19 | INDEX UNIQUE SCAN | HR_ORGANIZATION_UNITS_PK | 1 | 1 | 1 |00:00:00.01
|* 20 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_LINES_ALL | 1 | 2 | 3000 |00:01
|* 21 | INDEX RANGE SCAN | OE_ORDER_LINES_N20 | 1 | 47575 | 156K|00:00:01.76 | 420
|* 22 | TABLE ACCESS FULL | MTL_ITEM_CATEGORIES | 1 | 96977 | 263K|00:00:28.49
|* 23 | TABLE ACCESS BY INDEX ROWID | MTL_CATEGORIES_B | 3000 | 1 | 2990 |00:00:0
|* 24 | INDEX UNIQUE SCAN | MTL_CATEGORIES_B_U1 | 3000 | 1 | 3000 |00:00:00.21
| 25 | TABLE ACCESS BY INDEX ROWID | SEAENG_CCFAMILYMODELINFO | 2990 | 1 | 2990 |
|* 26 | INDEX UNIQUE SCAN | SEAENG_CCFAMILYMODELINFO_U1 | 2990 | 1 | 2990 |00:00:
|* 27 | INDEX UNIQUE SCAN | MTL_PARAMETERS_U1 | 2990 | 1 | 2990 |00:00:00.02 |
|* 28 | TABLE ACCESS BY INDEX ROWID | OE_ORDER_HEADERS_ALL | 2990 | 1 | 594 |00:00:
|* 29 | INDEX UNIQUE SCAN | OE_ORDER_HEADERS_U1 | 2990 | 1 | 2990 |00:00:04.29 |
| 30 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_SITE_USES_ALL | 594 | 1 | 594 |00:00:
|* 31 | INDEX UNIQUE SCAN | HZ_CUST_SITE_USES_U1 | 594 | 1 | 594 |00:00:00.31 |
| 32 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCT_SITES_ALL | 594 | 1 | 594 |00:00:
|* 33 | INDEX UNIQUE SCAN | HZ_CUST_ACCT_SITES_U1 | 594 | 1 | 594 |00:00:00.23 |
| 34 | TABLE ACCESS BY INDEX ROWID | HZ_PARTY_SITES | 594 | 1 | 594 |00:00:0
|* 35 | INDEX UNIQUE SCAN | HZ_PARTY_SITES_U1 | 594 | 1 | 594 |00:00:00.17 | 601
| 36 | TABLE ACCESS BY INDEX ROWID | HZ_LOCATIONS | 594 | 1 | 594 |00:00:00.4
|* 37 | INDEX UNIQUE SCAN | HZ_LOCATIONS_U1 | 594 | 1 | 594 |00:00:00.17 |
| 38 | TABLE ACCESS BY INDEX ROWID | FND_TERRITORIES | 594 | 1 | 594 |00:00:00
|* 39 | INDEX UNIQUE SCAN | FND_TERRITORIES_U1 | 594 | 1 | 594 |00:00:00.02
|* 40 | TABLE ACCESS BY INDEX ROWID | HZ_CUST_ACCOUNTS | 594 | 1 | 592 |00:00:0
|* 41 | INDEX UNIQUE SCAN | HZ_CUST_ACCOUNTS_U1 | 594 | 1 | 594 |00:00:00.04 |
|* 42 | INDEX RANGE SCAN | FND_LOOKUP_VALUES_U1 | 592 | 1 | 592 |00:00:00.06 |
| 43 | TABLE ACCESS BY INDEX ROWID | HZ_PARTIES | 592 | 1 | 592 |00:00:00.91 |
|* 44 | INDEX UNIQUE SCAN | HZ_PARTIES_U1 | 592 | 1 | 592 |00:00:00.40 | 599
Predicate Information (identified by operation id):
13 - access("OEL"."INVENTORY_ITEM_ID"="MIC"."INVENTORY_ITEM_ID")
17 - access("HAOTL"."ORGANIZATION_ID"=189 AND "HAOTL"."LANGUAGE"=USERENV('LANG'))
filter(DECODE("HR_SECURITY"."VIEW_ALL"(),'Y','TRUE',"HR_SECURITY"."SHOW_RECORD"('HR_ALL_ORGAN
18 - filter("HAO"."BUSINESS_GROUP_ID"=DECODE("HR_GENERAL"."GET_XBG_PROFILE"(),'Y',"HAO"."BUSINESS_
19 - access("HAO"."ORGANIZATION_ID"=189)
20 - filter(("OEL"."FLOW_STATUS_CODE"='CLOSED' AND INTERNAL_FUNCTION("OEL"."ATTRIBUTE1") AND INTER
21 - access("OEL"."SYS_NC00342$">=TO_DATE(' 2009-01-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "O
'syyyy-mm-dd hh24:mi:ss'))
22 - filter("MIC"."CATEGORY_SET_ID"=4)
23 - filter(("MC"."DESCRIPTION" IS NOT NULL AND INTERNAL_FUNCTION("MC"."SEGMENT7")))
24 - access("MIC"."CATEGORY_ID"="MC"."CATEGORY_ID")
26 - access("MC"."DESCRIPTION"="CCM"."STMODELNUMBER")
27 - access("OEL"."SHIP_FROM_ORG_ID"="MP"."ORGANIZATION_ID")
28 - filter("OEH"."ORG_ID"=189)
29 - access("OEH"."HEADER_ID"="OEL"."HEADER_ID")
31 - access("OEH"."INVOICE_TO_ORG_ID"="HCSU"."SITE_USE_ID")
33 - access("HCSU"."CUST_ACCT_SITE_ID"="HCAS"."CUST_ACCT_SITE_ID")
35 - access("HCAS"."PARTY_SITE_ID"="HPS"."PARTY_SITE_ID")
37 - access("HPS"."LOCATION_ID"="HL"."LOCATION_ID")
39 - access("HL"."COUNTRY"="FT"."TERRITORY_CODE")
40 - filter(("HCA"."SALES_CHANNEL_CODE"<>'RTL' AND "HCA"."SALES_CHANNEL_CODE"<>'AD-RTL' AND "HCA".
41 - access("HCAS"."CUST_ACCOUNT_ID"="HCA"."CUST_ACCOUNT_ID")
42 - access("FLV"."LOOKUP_TYPE"='SALES_CHANNEL' AND "FLV"."LOOKUP_CODE"="HCA"."SALES_CHANNEL_CODE"
filter(("FLV"."LOOKUP_CODE"<>'RTL' AND "FLV"."LOOKUP_CODE"<>'AD-RTL' AND "FLV"."LOOKUP_CODE"<
44 - access("HCA"."PARTY_ID"="HP"."PARTY_ID")
90 rows selected.
{code} &nbs -
How to get this sql query value in oracle query?
Hi all,
i am using one query in sql that is
select @EarlyLeaversMin = DATEDIFF(Minute,@OutTime,@nshiftmax)
suppose first line query is getting 60 minutes.
select @EarlyLeaversMin1=DATEDIFF(Minute,@temphrs,@ShiftTime)
second line query is also getting 60 minutes
set @EarlyLeaversMin=@EarlyLeaversMin+@EarlyLeaversMin1+1
and now here it's calculating both variable minutes and storing in @earlyleaversmin that should store like 60+60+1=121 mintes
select @EarlyLeaverstimeformat = CONVERT(char(8),Dateadd(n,@EarlyLeaversMin,0),108)
so now it will store in this query that value in this format : 01:21:00
can i use the same which it's happening here??
thanksOracle handles dates and time very differently from SQL Server (as I gather others on this forum have already tried to explain to you).
Anyway, Oracle does not have a TIME datetype, but what it does have are INTERVALs. In this case you would use INTERVAL DAY TO SECOND. It's not completely clear what you mean by "store in this query that value" but we can use INTERVALS as both table columns and PL/SQL variables.
So your first query would be something like this:
declare
interval_var INTERVAL DAY TO SECOND;
begin
select (nshiftmax - outtime) day to second
into interval_var
from whatever;We can do arithmetic with interval variables.
select (nshiftmax - outtime) day to second + (shifttime - temphrs) day to second
into interval_var
from whatever;To add a hard-coded interval such as 1 minute you can use this functionality:
interval_var := interval_var + to_dsinterval('0 0:1:0');There's loads of info in the Oracle documentation. [url http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements001.htm#sthref115]Find out more.
Cheers, APC
Maybe you are looking for
-
after updating iOS on my iPod touch 4th gen my Philips speaker dock DC290B/37 no longer charges the iPod. It will play music but not charge, is there anyway to find out if Apple is working on an update/fix?
-
Same logo printing different colors for different file formats?
I created a logo for a client who will be using it for some printed materials. I provided the logo in 3 different file formats: EPS, JPEG and Tiff. In INDesign and MS Word, the logo is printing a different color for the EPS vs the Jpeg/Tiff file typ
-
Quicktime not playing after publishing page
I have a 13MB .mov quicktime which plays fine not only in iWeb and on its own, but plays when I put it loose in the Site folder and direct the browser to it, however when I add it to my site via iWeb and then publish, it shows up with a question mark
-
Serial number skips in RG23C part2
Dear Experts, we have problem in Serial numbers in RG23 C part II statement, some serial numbers are missing in the statement, and we could not trace whether it was generated or not! there are nearly 15(Continuous) numbers are missing in the stateme
-
how can i edit a clip or share it. I cant change the sencond the clips lasts or insert an image or a text! whats going on???