Help Needed Writing Query
Hi Users,
I have a table which has the records inserted on every Saturday (i:e on a weekly basis).
The table "NCIM" has the following records in it
NODE INTERFACE CREATEDATE
172.29.58.195 4 1/1/2011
172.29.60.1 11 1/1/2011
172.16.10.44 3 1/1/2011
172.29.58.195 4 25/12/2010
172.29.60.1 11 25/12/2010
172.16.10.44 3 25/12/2010
172.29.58.195 2 18/12/2010
172.29.60.1 8 18/12/2010
172.16.10.44 5 18/12/2010
172.29.58.195 6 11/12/2010
172.29.60.1 22 11/12/2010
172.16.10.44 7 11/12/2010The requirement is to find, what was the "INTERFACE" value for the particular NODE on the particular window period.
1) When I run the query any time in the current week (between Jan 1st and Jan 7th 2011) then
my output should be
NODE INTERFACE CREATEDATE
172.29.58.195 4 1/1/2011
172.29.60.1 11 1/1/2011
172.16.10.44 3 1/1/20112) When I run the query with the condition for the last two week from the current date (subtracting 14 days from current date 4th Jan is Dec 22nd 2010) falling between Dec 18th and Dec 25th. So the output should be
NODE INTERFACE CREATEDATE
172.29.58.195 2 18/12/2010
172.29.60.1 8 18/12/2010
172.16.10.44 5 18/12/2010Can some please help how to accomplish this with the query.
Thanks.
RR
Hi,
you can use the solution from frank or if you have real dates for the select, you can do it with a simple date_field <to_date('25.12.2010','DD.MM.YYYY') and date_field>=to_date('18.12.2010','DD.MM.YYYY')
Regards
Udo
SQL> create table a_table (interface number,date_field date);
Tabelle wurde angelegt.
SQL> insert into a_table (interface,date_field) values(1,to_date('11.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(2,to_date('11.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(3,to_date('11.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(4,to_date('18.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(5,to_date('18.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(6,to_date('18.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(7,to_date('25.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(8,to_date('25.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(9,to_date('25.12.2010','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(10,to_date('01.01.2011','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(11,to_date('01.01.2011','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(12,to_date('01.01.2011','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(13,to_date('08.01.2011','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(14,to_date('08.01.2011','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL> insert into a_table (interface,date_field) values(15,to_date('08.01.2011','DD.MM.YYYY'));
1 Zeile wurde erstellt.
SQL>
SQL> select * from a_table where date_field <=sysdate and date_field>=sysdate-7;
INTERFACE DATE_FIE
10 01.01.11
11 01.01.11
12 01.01.11
SQL> select * from a_table where date_field <to_date('25.12.2010','DD.MM.YYYY') and date_field>=to_date('18.12.2010','DD.MM.YYYY');
INTERFACE DATE_FIE
4 18.12.10
5 18.12.10
6 18.12.10
Similar Messages
-
Need helping in writing query for finding percentage of duration
Can any one please help in writing query for this.
The table is like this :-
ID Region Month Duration
I1 R1 Jan 80
I2 R2 Jan 70
I3 R1 Jan 70
I4 R3 Jan 40
I5 R1 Feb 80
I6 R2 Feb 30
I7 R3 Mar 100
I want to write a query to find
% of duration for each and every region against each and every month.
Please help in solving this query. I am in urgent need of this.
Thanks in advance.I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
Nicolas. -
I have one table Prd_mst, I need a query or function where whenever i pass the child_id into query or function i get the Parent_id of that
example Data is below :-
P_ID,P_NAME,C_ID
null,Computer,1
1,KeyBoard,2
1,Mouse,3
1,Mother Board,4
3,Scroll Mouse,5
3,Optical Scroll Mouse,6
3,Fibre Scroll Mouse,7
2,Multimedia Key Board,8
2,Cordless Key Board,10
2,Normal Key Board,9
4,586 Mother Board,13
4,386 Mother Board,11
4,486 Mother Board,12
4,P1 Mother Board,14
4,P2 Mother Board,15
4,P3 Mother Board,16
4,P4 Mother Board,17
14,533 Mhtz P1 CPU,19
14,433 Mhtz P1 CPU,18
19,533 Mhtz P1 CPU With 100Mhtz BUS,20
19,533 Mhtz P1 CPU With 133Mhtz BUS,21
18,433 Mhtz P1 CPU With 100Mhtz BUS,22
So when ever i put the child id as 22 i should get the 14
So when ever i put the child id as 21 i should get the 14
So when ever i put the child id as 9 i should get the 1
So when ever i put the child id as 15 i should get the 1
So when ever i put the child id as 5 i should get the 1
So when ever i put the child id as 3 i should get the null
So when ever i put the child id as 14 i should get the 1.
Please help me......
There is one complex requirement in matrix format.
Need P_ID , P_NAME , Count( child records)
P_(nth), P_NAME(nth), Count(child record) nth times.
Child is again the parent of some child.
Report is needed for audit purpose.
Message was edited by: Sandeep Sharma
Sandeep SharmaSQL> CREATE TABLE SANDEEP(P_ID NUMBER,P_NAME VARCHAR2(100),C_ID NUMBER);
Table created.
SQL> INSERT INTO SANDEEP VALUES(null,'Computer',1);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(1,'KeyBoard',2);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(1,'Mouse',3);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(1,'Mother Board',4);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(3,'Scroll Mouse',5);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(3,'Optical Scroll Mouse',6);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(3,'Fibre Scroll Mouse',7);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(2,'Multimedia Key Board',8);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(2,'Cordless Key Board',10);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(2,'Normal Key Board',9);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(4,'586 Mother Board',13);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(4,'386 Mother Board',11);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(4,'486 Mother Board',12);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(4,'P1 Mother Board',14);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(4,'P2 Mother Board',15);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(4,'P3 Mother Board',16);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(4,'P4 Mother Board',17);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(14,'533 Mhtz P1 CPU',19);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(14,'433 Mhtz P1 CPU',18);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(19,'533 Mhtz P1 CPU With 100Mhtz BUS',20);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(19,'533 Mhtz P1 CPU With 133Mhtz BUS',21);
1 row created.
SQL> INSERT INTO SANDEEP VALUES(18,'433 Mhtz P1 CPU With 100Mhtz BUS',22);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> set null null
SQL> SELECT P_ID
2 FROM SANDEEP
3 WHERE LEVEL = 2
4 START WITH C_ID = &1
5 CONNECT BY C_ID = PRIOR P_ID;
Enter value for 1: 22
old 4: START WITH C_ID = &1
new 4: START WITH C_ID = 22
P_ID
14
SQL> /
Enter value for 1: 21
old 4: START WITH C_ID = &1
new 4: START WITH C_ID = 21
P_ID
14
SQL> /
Enter value for 1: 9
old 4: START WITH C_ID = &1
new 4: START WITH C_ID = 9
P_ID
1
SQL> /
Enter value for 1: 15
old 4: START WITH C_ID = &1
new 4: START WITH C_ID = 15
P_ID
1
SQL> /
Enter value for 1: 5
old 4: START WITH C_ID = &1
new 4: START WITH C_ID = 5
P_ID
1
SQL> /
Enter value for 1: 3
old 4: START WITH C_ID = &1
new 4: START WITH C_ID = 3
P_ID
null
SQL> /
Enter value for 1: 14
old 4: START WITH C_ID = &1
new 4: START WITH C_ID = 14
P_ID
1
SQL> SY. -
Help needed in query for Materialized View
Hi,
I want to create a materialized view which has some precalcultaed values.
I have four dimension tables out of which one is a Time Dimension table with levels as Year->Quarter->Month.
The precalculations are the moving averages and cummulative values of Sales Amt on the dimension values over a period of 4 Months.
The dimension tables are Clients, Products, Channel, Time.
Fact Table is Sales_Fact which will have the sales amount for different members of the dimension.
Since my fact table is very huge, i want to create a materialized view where i could store the required calculated measures, here Moving Average of Sales Amt for each Client, Product, Channel dimensions over a period of 4 Months.
Can anybody help with writing the query for this..Any help in this regard will be appreciated..
Please give me suggestions for this..Check this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
Help in writing query few schema objects from another schema.
Hi Gurus,
Could some one help in writing an sql which will give list of all the object of a schema "genp" visible in another schema "genp_v" and "gen_con" there is an dblink and few grants on those schemas .
i dont have the password of any of those users i have connected as sys and i can not change the password of any of those users..
Any help on this is highly apprciated.
Thanks in advance .could you please update me for all the objects apart from just the tables .
thank you so much .. it was just out of my head at that moment .
cheers -
Hi,
I've select query to retrive the data in the following order
Sequnce ID Model Barcode
1 Dell 123
2 Dell 124
3 Dell 125
4 HP 126
5 hp 127
6 hp 128
7 apple 129
8 apple 130
I want the following to be selected round robin for Dell and Hp laptop alone as mentioned below.
Sequnce ID Model Barcode
1 Dell 123
4 HP 126
2 Dell 124
5 hp 127
3 Dell 125
6 hp 128
7 apple 129
8 apple 130
Can you help me to acheive this?
Thanks!Hi,
user601042 wrote:
Hi,
I've select query to retrive the data in the following order
Sequnce ID Model Barcode
1 Dell 123
2 Dell 124
3 Dell 125
4 HP 126
5 hp 127
6 hp 128
7 apple 129
8 apple 130If that's what you want, then it looks like
ORDER BY barcodeis all you need.
If you want the results sorted as below, Then you can use the analytic ROW_NUMBER function:
ORDER BY CASE
WHEN UPPER (model) IN ('DELL', 'HP')
THEN ROW_NUMBER () OVER ( PARTITION BY UPPER (model)
ORDER BY barcode
END
, barcode
I want the following to be selected round robin for Dell and Hp laptop alone as mentioned below.
Sequnce ID Model Barcode
1 Dell 123
4 HP 126
2 Dell 124
5 hp 127
3 Dell 125
6 hp 128
7 apple 129
8 apple 130Either way, I assume that sequnce id is not actually in your table.
Edited by: Frank Kulash on Mar 14, 2013 12:38 PM
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
EMP_ID EMP_NAME
1 PAULA
2 JOHN
3 RADHA
4 RADHA
5 RAM
6 RAM
7 RAM
8 PATRICK
9 PADMA
10 SALMAN
Write a query that gives all names that occur more than three times in the company.Hi,
Also, look up the aggregate COUNT function.
COUNT, GROUP BY and HAVING are all described in the [SQL Language Reference manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/index.htm], though, if you have a textbook, you should look at the textbook first. -
Hello Query experts,
I have the following data in my DSO.
Char1 date Kf1 KF2
a 01.01.2011 10 20
a 03.01.2011 50 70
a 05.01.2011 5 10
b 02.01.2011 20 25
b 05.01.2011 10 15
b 06.01.2011 5 15
Now, I need to design a query to produce the following result:
Char1 date Kf1 KF2 KF3(KF2-KF1) KF4
a 01.01.2011 10 20 10 10
a 03.01.2011 50 70 20 30 [KF3+Prev(KF4)]
a 05.01.2011 5 10 5 35
b 02.01.2011 20 25 5 5
b 05.01.2011 10 15 5 10
b 06.01.2011 5 15 10 20
Can anybody help me achieve this through a BI Query?
Thanks and regards,
JashuaHI,
I think kf3 can easily be created at query level itself without writing complex logic..As far as i understand your requirement kf3 is a differnce of kf2 and kf1.
so jst make local formula and in that put kf2-kf1.it will give you the desired output for kf3.
Kf4 i need to think,i will update you soon -
SQL HELP NEEDED IN QUERY FOR COUNT
I Have this Query
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE IN ('02', '03', '04') THEN 1 END) AS VET_YES,
SUM (CASE WHEN b.VET_OTHR_ELIG_CDE = '01' THEN 1 END) VET_NO, COUNT (E.ACTV_CDE) AS CNT_ACTV_CDE
Now i need to Add two more columns from the same Query Showing the count of VET_YES and VET_NO i.e count of TOTAL Veterans And TOTAL Non Veterans
those two columns i will be using as summary columns in my report.The bolded columns are those which i need to show the total column .anyone please help in this issue ..
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_ACTV_CDE
INACT DUE 13993 2 1 3
NOW I NEED TO MAKE IT LIKE THIS
ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_VET CNT_NONVET CNT_ACTV_CDE (This is the total count)
INACT DUE 13993 2 1 2 1 3
Thanks in Advance,
Dev Kishore.T
Message was edited by:
Dev Kishore
Message was edited by:
Dev KishoreCheck this link.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
Regards
Raj -
I have troubles with my XML query. It returns to many results and double results.
My code
select xmlelement("test", XMLAgg(xmlelement("Customer", XmlAttributes(a.CUSTOMER_ID "cid"))),
XMLAgg(xmlelement("Account", xmlagg(xmlelement("Account", b.ACCOUNT_ID) ))),
XMLAgg(xmlelement("ServicePoint", xmlagg(xmlelement("sp", c.SPID) ))) ).extract('*').getstringval() xml
From DM_SERVICE_POINT c, DM_CUSTOMER a, DM_ACCOUNT b where a.CUSTOMER_ID = b.CUSTOMER_ID And a.CUSTOMER_ID=c.CUSTOMER_ID AND a.CUSTOMER_ID='15058'
group by a.CUSTOMER_ID
i have 1 customer id in the table dm_customer, 2 account_id 's that are linked to customer_id with a FK. DM_Servicepoint contains 6 rows that are linked to dm_customer with a FK.
My result is 1 result for customer, thats correct but account shows 12 results, where i expect 2 results
and Service point shows also 12 records where i expect 6 records.
There is no direct link between account and service point but both are linked to customer. Each customer can have 1 or 2 account And each customer can have 1 or many servicepoints.
Can you help me?
Message was edited by:
MarindaNow to see whether we can get this to work with XML....Turns out it's a lot easier than I thought it would be:
SQL> select dbms_xmlgen.getxml('select c.name
2 , cursor(select a.acctno, a.name
3 from my_accounts a
4 where a.cust_id = c.id ) as accounts
5 , cursor(select s.sp_ref
6 from my_service_points s
7 where s.cust_id = c.id ) as srv_points
8 from my_customers c
9 ') from dual
10 /
DBMS_XMLGEN.GETXML('SELECTC.NAME,CURSOR(SELECTA.ACCTNO,A.NAMEFROMMY_ACCOUNTSAWHE
<?xml version="1.0"?>
<ROWSET>
<ROW>
<NAME>APC</NAME>
<ACCOUNTS>
<ACCOUNTS_ROW>
<ACCTNO>900000</ACCTNO>
<NAME>No1 a/c</NAME>
</ACCOUNTS_ROW>
<ACCOUNTS_ROW>
<ACCTNO>900002</ACCTNO>
<NAME>Business</NAME>
</ACCOUNTS_ROW>
</ACCOUNTS>
<SRV_POINTS>
<SRV_POINTS_ROW>
<SP_REF>SP1</SP_REF>
</SRV_POINTS_ROW>
<SRV_POINTS_ROW>
<SP_REF>SP2</SP_REF>
</SRV_POINTS_ROW>
<SRV_POINTS_ROW>
<SP_REF>SP3</SP_REF>
</SRV_POINTS_ROW>
<SRV_POINTS_ROW>
<SP_REF>SP4</SP_REF>
</SRV_POINTS_ROW>
<SRV_POINTS_ROW>
<SP_REF>SP5</SP_REF>
</SRV_POINTS_ROW>
<SRV_POINTS_ROW>
<SP_REF>SP6</SP_REF>
</SRV_POINTS_ROW>
</SRV_POINTS>
</ROW>
<ROW>
<NAME>MARINDA</NAME>
<ACCOUNTS>
<ACCOUNTS_ROW>
<ACCTNO>900004</ACCTNO>
<NAME>Checking</NAME>
</ACCOUNTS_ROW>
</ACCOUNTS>
<SRV_POINTS>
<SRV_POINTS_ROW>
<SP_REF>SP7</SP_REF>
</SRV_POINTS_ROW>
<SRV_POINTS_ROW>
<SP_REF>SP8</SP_REF>
</SRV_POINTS_ROW>
</SRV_POINTS>
</ROW>
</ROWSET>
SQL> Obviously you'll need to do some smartening up of the tag names.
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/ -
Help needed in query optimization.....
Hi
I have this below query which automatically gets generated in siebel.
Problem is when i execute this query in toad for "Nichole" it took 2 mins to return 30 records but when i execute this same query for "Adam" it returns more records than Nichole and return results in 1-2 secs. i Know executing query in toad is not a proper way but this below query will get executed in same way thru siebel application. Histogram is already created on column "Name" but of no help. Composite Index(CX_AA_EVNT_RADIO_BATCH_TIME) is there on column bot_id & timestp.
Table s_org_ext has only 5 records of "Nichole" and 10 records of "Adam".
Will including Column "Name" in Above composite index can help?
Please anybody can suggest me anything in this? whatelse i can do to tune this query?
Thanks for your help in advance
Chandan Singh
Also, don't know how better i can format this code :-(
SELECT t7.conflict_id, t7.last_upd, t7.created, t7.last_upd_by,
t7.created_by, t7.modification_num, t7.row_id, t7.last_upd,
t7.aa_acount_id, t7.aa_last_step, t7.accessory, t7.account_exists,
t7.account_number, t7.actn_cd, t7.action_counter, t7.activated_by,
t7.address, t7.address_2, t7.address_validation_status,
t4.account_name, t7.aggregated_account_id, t7.aggregated_flag,
t7.asset_id, t7.auto_delivery_type, t7.auto_make, t7.auto_model,
t7.auto_year, t7.automated_approval, t7.activation_frequency,
FROM siebel.s_prod_int t1,
siebel.s_org_ext t2,
siebel.s_asset t3,
siebel.av_account t4,
siebel.s_org_ext t5,
siebel.s_prod_int_x t6,
siebel.av_event t7
WHERE t1.row_id = t6.par_row_id(+)
AND t7.promotion_code = t1.part_num(+)
AND t7.asset_id = t3.row_id(+)
AND t3.owner_accnt_id = t5.par_row_id(+)
AND t7.id = t2.par_row_id --- S_ORG_EXT_U3
AND t7.id1 = t4.row_id(+)
AND (t2.NAME = 'Nichole')
ORDER BY t7.bot_id, t7.timestp
Below is the execution plan for above query.
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=399904 Card=5609601 Bytes=4930839279)
1 0 NESTED LOOPS (OUTER) (Cost=399904 Card=5609601 Bytes=4930839279)
2 1 NESTED LOOPS (OUTER) (Cost=343808 Card=5609601 Bytes=4824256860)
3 2 NESTED LOOPS (OUTER) (Cost=231616 Card=5609601 Bytes=4740112845)
4 3 NESTED LOOPS (OUTER) (Cost=175520 Card=5609601 Bytes=4482071199)
5 4 NESTED LOOPS (OUTER) (Cost=119424 Card=5609601 Bytes=4325002371)
6 5 NESTED LOOPS (Cost=63328 Card=5609601 Bytes=4240858356)
7 6 TABLE ACCESS (BY INDEX ROWID) OF 'av_event' (Cost=6729 Card=5659910 Bytes=4126074390)
8 7 INDEX (FULL SCAN) OF 'av_event_timpstp' (NON-UNIQUE) (Cost=24559 Card=5659910)
9 6 TABLE ACCESS (BY INDEX ROWID) OF 'S_ORG_EXT' (Cost=1 Card=1 Bytes=27)
10 9 INDEX (UNIQUE SCAN) OF 'S_ORG_EXT_U3' (UNIQUE)
11 5 TABLE ACCESS (BY INDEX ROWID) OF 'S_PROD_INT' (Cost=1 Card=1 Bytes=15)
12 11 INDEX (RANGE SCAN) OF 'S_PROD_INT_M3' (NON-UNIQUE)
13 4 TABLE ACCESS (BY INDEX ROWID) OF 'av_account' (Cost=1 Card=1 Bytes=28)
14 13 INDEX (UNIQUE SCAN) OF 'av_account_P1' (UNIQUE)
15 3 TABLE ACCESS (BY INDEX ROWID) OF 'S_ASSET' (Cost=1 Card=1 Bytes=46)
16 15 INDEX (UNIQUE SCAN) OF 'S_ASSET_P1' (UNIQUE)
17 2 TABLE ACCESS (BY INDEX ROWID) OF 'S_PROD_INT_X' (Cost=1 Card=1 Bytes=15)
18 17 INDEX (RANGE SCAN) OF 'S_PROD_INT_X_U1' (UNIQUE) (Cost=1 Card=1)
19 1 TABLE ACCESS (BY INDEX ROWID) OF 'S_ORG_EXT' (Cost=1 Card=1 Bytes=19)
20 19 INDEX (UNIQUE SCAN) OF 'S_ORG_EXT_U3' (UNIQUE)
Below is the No. of records in each table.
NUM_ROWS LAST_ANALYZED TABLE_NAME BLOCKS
5,594,027.00 09/08/2006 03:03:02 av_account 92,565.00
6,659,910.00 09/22/2006 16:14:06 av_event 608,292.00
15,384,080.00 09/22/2006 15:28:04 S_ASSET 1,244,124.00
10,249,905.00 04/23/2006 23:51:44 S_ORG_EXT 2,313,814.00
1,081.00 09/22/2006 15:26:12 S_PROD_INT 129.00
602.00 09/08/2006 04:39:42 S_PROD_INT_X 10.00can you plz try this
SELECT /*+ LEADING(t2) */ t7.conflict_id, t7.last_upd, t7.created, t7.last_upd_by,
t7.created_by, t7.modification_num, t7.row_id, t7.last_upd,
t7.aa_acount_id, t7.aa_last_step, t7.accessory, t7.account_exists,
t7.account_number, t7.actn_cd, t7.action_counter, t7.activated_by,
t7.address, t7.address_2, t7.address_validation_status,
t4.account_name, t7.aggregated_account_id, t7.aggregated_flag,
t7.asset_id, t7.auto_delivery_type, t7.auto_make, t7.auto_model,
t7.auto_year, t7.automated_approval, t7.activation_frequency,
FROM siebel.s_prod_int t1,
siebel.s_org_ext t2,
siebel.s_asset t3,
siebel.av_account t4,
siebel.s_org_ext t5,
siebel.s_prod_int_x t6,
siebel.av_event t7
WHERE t1.row_id = t6.par_row_id(+)
AND t7.promotion_code = t1.part_num(+)
AND t7.asset_id = t3.row_id(+)
AND t3.owner_accnt_id = t5.par_row_id(+)
AND t7.id = t2.par_row_id --- S_ORG_EXT_U3
AND t7.id1 = t4.row_id(+)
AND (t2.NAME = 'Nichole')
ORDER BY t7.bot_id, t7.timestp -
Hi All,
I am using the following queries in formula columns of a 6i report. The query count for these queries as seen from the trc file is very high, which is causing performance issues in the report.
Can anyone please help me to tune these queries.
SELECT ROUND (SUM (pld.denom_burdened_cost))
FROM pa_project_asset_lines_v pl,
gl_code_combinations glcc,
pa_asset_line_details_v pld
WHERE pl.project_asset_line_detail_id = pld.project_asset_line_detail_id
AND glcc.code_combination_id = pl.cip_ccid
AND transfer_status_code = 'T'
AND pld.project_id = :b1
AND glcc.segment2 = '131340'
Query Count - 1579401
SELECT SUM (DECODE (ei.system_linkage_function,
'ST', DECODE (pa_security.view_labor_costs (:b1),
'Y', ei.project_burdened_cost,
NULL
'OT', DECODE (pa_security.view_labor_costs (:b1),
'Y', ei.project_burdened_cost,
NULL
ei.project_burdened_cost
) aa
FROM pa_expenditure_items_all ei, pa_tasks t
WHERE ei.project_id = :b1
AND pa_expenditures_utils.get_latest_gl_date (ei.expenditure_item_id)
BETWEEN :b4
AND :b5
AND ei.org_id = fnd_profile.VALUE ('ORG_ID')
AND ei.project_id = t.project_id
AND NVL (t.billable_flag, 'N') = 'N'
Query Count - 1969414
SELECT SUM (DECODE (ei.system_linkage_function,
'ST', DECODE (pa_security.view_labor_costs (:b1),
'Y', ei.project_burdened_cost,
NULL
'OT', DECODE (pa_security.view_labor_costs (:b1),
'Y', ei.project_burdened_cost,
NULL
ei.project_burdened_cost
) aa
FROM pa_cost_distribution_lines_all pcd,
gl_code_combinations glcc,
pa_expenditure_items_all ei,
pa_tasks t
WHERE ei.project_id = :b1
AND pa_expenditures_utils.get_latest_gl_date (ei.expenditure_item_id)
BETWEEN :b4
AND :b5
AND ei.org_id = fnd_profile.VALUE ('ORG_ID')
AND pcd.dr_code_combination_id = glcc.code_combination_id
AND glcc.segment2 != '131340'
AND ei.project_id = pcd.project_id
AND ei.expenditure_item_id = pcd.expenditure_item_id
AND t.project_id = ei.project_id
AND t.billable_flag = 'Y'
Query Count - 1973901
Regards,
ShrutiThis statement
SELECT SUM (DECODE (ei.system_linkage_function,
'ST', DECODE (pa_security.view_labor_costs (:b1),
'Y', ei.project_burdened_cost,
NULL
'OT', DECODE (pa_security.view_labor_costs (:b1),
'Y', ei.project_burdened_cost,
NULL
ei.project_burdened_cost
) aa
FROM pa_expenditure_items_all ei, pa_tasks t
WHERE ei.project_id = :b1
AND pa_expenditures_utils.get_latest_gl_date (ei.expenditure_item_id)
BETWEEN :b4
AND :b5
AND ei.org_id = fnd_profile.VALUE ('ORG_ID')
AND ei.project_id = t.project_id
AND NVL (t.billable_flag, 'N') = 'N'uses at least 3 different functions inside the SQL.
<ul><li>pa_security.view_labor_costs (:b1)</li>
<li>fnd_profile.VALUE ('ORG_ID')</li>
<li>pa_expenditures_utils.get_latest_gl_date (ei.expenditure_item_id)</li>
</ul>
Each function call might result in a context switch from SQL to pl/SQL and back. This is expensive and slow. For each line 4 functions are called. Which means 8 context switches per base line. In your case aproximately 16 million switches.
You can try to avoid this context switch.
The first and second function an be encapsulated in a with query wich should result in a single call. The logic in the second function should be rewritten iinto pure SQL.
This can make a huge difference.
example untested
with singlerowdata as (select pa_security.view_labor_costs (:b1) v_labor_costs, fnd_profile.VALUE ('ORG_ID') profile_org_id from dual)
SELECT SUM (DECODE (ei.system_linkage_function,
'ST', DECODE (s.v_labor_costs,
'Y', ei.project_burdened_cost,
NULL
'OT', DECODE (s.v_labor_costs,
'Y', ei.project_burdened_cost,
NULL
ei.project_burdened_cost
) aa
FROM pa_expenditure_items_all ei, pa_tasks t, singlerowdata s
WHERE ei.project_id = :b1
/* "the latest date can also be found with an analytic function, but there is not enough information to show how to do it here"
This would potentially improve the performance even more. */
AND (select max(datecolumn) from pa_expenditure_items x where x.id = ei.expenditure_item_id) BETWEEN :b4 AND :b5
AND ei.org_id = s.profile_org_id
AND ei.project_id = t.project_id
AND NVL (t.billable_flag, 'N') = 'N' -
Hi All,
I have a table structure along with sample data like this
ID PatID Lastname Firstname DOS
1 2 aaa xxx 11/12/20013
2 1 bbb xxx 11/12/20013
3 3 ccc xxx 10/12/20013
4 1 bbb xxx 11/11/20013
5 2 aaa xxx 11/10/20013
6 1 bbb xxx 11/10/20013
7 2 aaa xxx 11/09/20013
8 3 ccc xxx 11/09/20013
My requirement is that if there are more than one record with the PatID for First record the last name should be displayed from 2nd record on words in last name null value should be displayed like this.
ID PatID Lastname Firstname DOS
1 1 aaa xxx 11/12/20013
2 1 xxx 11/12/20013
3 1 xxx 10/12/20013
4 2 bbb xxx 11/11/20013
5 2 xxx 11/10/20013
6 2 xxx 11/10/20013
7 3 ccc xxx 11/09/20013
8 3 xxx 11/09/20013
Please guide me on this.
Waiting for valuable replies.
Thanks and Regards
Sridhar.RThis is quite complex query, but my idea above applies.
;with cte AS (SELECT DISTINCT Rxs.FacID, Rxs.RxNo, Rxs.RxBatch, Patients.PatLName, Patients.PatFName, Rxs.InitReview, Rxs.LabelPrintedOn, Rxs.Packed, Rxs.PlacedInTote, Patients.Street1, Patients.Zip, RxBatches.BatchDescr, ROW_NUMBER() OVER (partition by Patients.PatId ORDER BY Patients.PatFnName) AS Rn
FROM FwReports.dbo.Patients Patients
INNER JOIN FwReports.dbo.Rxs Rxs ON Rxs.PatID = Patients.PatID
INNER JOIN FwReports.dbo.RxBatches RxBatches
ON RxBatches.RxBatch = Rxs.RxBatch AND RxBatches.FacID = Rxs.FacID AND RxBatches.PharmID = Rxs.PharmID
WHERE ((Rxs.RxBatch Like 's%' And Rxs.RxBatch<>'eileen' And Rxs.RxBatch Like 'STAT%') AND (Rxs.ProfileOnly=0) AND (Rxs.TransType<>'B' And Rxs.TransType<>'B') AND (Rxs.DrugLabelName Not Like 'delivery%') OR (Rxs.RxBatch<>'eileen' And Rxs.RxBatch Like 'STAT%') AND (Rxs.TransType<>'B' And Rxs.TransType<>'B') AND (Rxs.DrugLabelName Not Like 'delivery%') AND (Rxs.FacID In ('crh') And Rxs.FacID='CRH') OR (Rxs.FacID='CRH') OR (Rxs.FacID In ('CRH','LSRX')) OR (Rxs.FacID In ('CRH','LSRX'))))
SELECT FacId, RxNo, RxBatch, case when Rn = 1 then PatLName end as PatLName, PatFName, ...
FROM cte
I didn't list every column and I am not sure what column do you need to use in ORDER BY clause, but you should get the idea.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Help needed with query.....
I have a table TableA with two columns
ColA, DateCol
The data is as follows:
Table A
ColA DateCol
A 03-JUL-07
B 15-DEC-07
C 25-MAR-08
D 11-AUG-07
E 31-AUG-07
F 29-FEB-08 I want to generate data something as follows and insert into another table TableB which has columns ValueColA, DateColA:
If the value in ColA has date as 03-JUL-07, then for that value i want to generate all the dates after JUL-07 till JUN-08 something like this
Table B
ValueColA DateColA
A 01-JUL-07
A 01-AUG-07
A 01-SEP-07
A 01-OCT-07
A 01-NOV-07
A 01-DEC-07
A 01-JAN-08
A 01-FEB-08
A 01-MAR-08
A 01-APR-08
A 01-MAY-08
A 01-JUN-08If B has date 15-DEC-07 then values after DEC-07 to JUN-08
Table B
ValueColA DateColA
B 01-DEC-07
B 01-JAN-08
B 01-FEB-08
B 01-MAR-08
B 01-APR-08
B 01-MAY-08
B 01-JUN-08If C has date 25-MAR-08 then values after MAR-08 to JUN-08
Table B
ValueColA DateColA
C 01-MAR-08
C 01-APR-08
C 01-MAY-08
C 01-JUN-08Is it possible to achieve this way using query..IF anybody can help me with this...Please...SQL> with t as
2 (
3 select 'A' id, to_date('03-JUL-07','dd-mon-yy') dt from dual union all
4 select 'B', to_date('15-DEC-07','dd-mon-yy') from dual union all
5 select 'C', to_date('25-MAR-08','dd-mon-yy') from dual
6 ),
7 months as (
8 select add_months(date '2007-07-01', level - 1) as month
9 from dual
10 connect by level <= 12
11 )
12 select t.id, M.month
13 from t, months M
14 where trunc(t.dt, 'month') <= M.month
15 order by id, M.month
16 ;
I MONTH
A 01.07.2007
A 01.08.2007
A 01.09.2007
A 01.10.2007
A 01.11.2007
A 01.12.2007
A 01.01.2008
A 01.02.2008
A 01.03.2008
A 01.04.2008
A 01.05.2008
A 01.06.2008
B 01.12.2007
B 01.01.2008
B 01.02.2008
B 01.03.2008
B 01.04.2008
B 01.05.2008
B 01.06.2008
C 01.03.2008
C 01.04.2008
C 01.05.2008
C 01.06.2008
23 rows selected.Regards,
Dima -
Hi All,
I am using Oracle 11g version.
Could you please help me on this
i have table like this
personid planid rate
1 poo1 500
2 poo1 500
3 poo2 200
4 p003 100
But i want to get output like this
personid planid rate
1 p001 500
2
3 poo2 200
4 p003 100LRAJESH wrote:
Hi All,
I am using Oracle 11g version.
Could you please help me on this
i have table like this
personid planid rate
1 poo1 500
2 poo1 500
3 poo2 200
4 p003 100
But i want to get output like this
personid planid rate
1 p001 500
2
3 poo2 200
4 p003 100Depending on the context of the query,, it could be as simple as issueing a sqlplus BREAK command.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch6.htm#sthref1252
Maybe you are looking for
-
Why is it so difficult to link accounts? Or log in...
I ended up in a chat session with support yesterday - and there didn't seem to be much choice except to link the outlook account that the desktop version wants with my Skype account. After the chat, the accounts were linked correctly - and today, th
-
Adobe Photoshop Elements 6 (Is this deal legit?)
Hi everyone, I've just stumbled across the following site where you can purchase a download version of Elements 6 for the mac os at a very good price: http://shop.ddscomputing.co.uk/isc502/products/Adobe-Photoshop-Elements-6-(MAC)-.html Is this the r
-
Serial Number in report name aswell as report body ?
Hello I am fairly new to TS, I am using the Single Pass Execution entry point with a sequence I have written. I have written my own LabVIEW based Barcode Scanning Module for getting the DUT Serial Number from the user (As the Single Pass doesn't incl
-
I have made a book of 26 pages with photos and text, but I cannot order the book, since the menu " buy the book" remains in grey. 2 pages have a warning sign, but I don't understand why. One is with one photo and a column of text. The sign is on the
-
Adding directional blur to adjustment layer/nested sequence
When adding a directional blur to adjustment layer or a nested sequence in MPE hardware mode the sides get dark (alpha channel shows). When turning MPE off the issue is gone. Already submitted a bugreport but found out its MPE hardware. Seen this iss