SQL & PL/SQL :: Sum (cost) Basing On ID Entered
Oct 1, 2012
my data :
id cost
aa_aa 100
ab_aa 100
bb_bb 100
ba_bb 100
ab_aa 100
I need to get my data as
if id like 'aa_%' then it should sum cost for ids for aa_aa and ab_aa and print only 1 row with putput as
id cost
aa_aa 300
If id is like 'ab_%' then it should sum up
ids only for ab_aa..
Output as:
id cost
ab_aa 200
View 7 Replies
ADVERTISEMENT
Sep 28, 2010
I was questioned in an interview what is the unit of cost and based on what was it calculated.
View 1 Replies
View Related
Sep 2, 2010
I am using oracle 10g, i want to know the cost of query. In the explain plan and by auto trace am able to get some query cost, but i dont know how to calculate the query cost.
How i will know the query is costly and take more time..? But i know about the hash table and nested tables in the explain plan.
Other than this how to calculate the query cost..?
View 5 Replies
View Related
May 24, 2013
select *from v$version where rownum=1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
prepare data:
CREATE TABLE a AS SELECT LEVEL ID ,decode(mod(LEVEL,10),1,'CODE'||LEVEL) CODE from dual CONNECT BY LEVEL<20001;
sql1:
CREATE TABLE TEST AS
SELECT ID,
NVL(CODE,LAG(CODE ignore nulls) OVER(ORDER BY ID )) CODE
FROM a;
the sql is slow,most of the waits on session is resmgr:cpu quantum and almost all of the cpu resource is occupied
sql2:
CREATE TABLE TEST AS
SELECT ID,
NVL(CODE,last_value(CODE ignore nulls) OVER(ORDER BY ID ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING)) CODE
FROM a;
this sql is fast
How lag function is implemented if the offset is not deterministic?
View 10 Replies
View Related
Oct 5, 2010
I am trying to insert data from 9i to 11g using db link with the below query but while doing so the select statement is going for a full table scan even though rowid is used. But when we execute the same select statement without this insert command it is using proper index. Similar issues I am facing for updates.
Query:
INSERT INTO /*+ APPEND */ emp@db_link
select *
from emp where rowid ='AAC2SmAIIAAAHQgAAZ'
View 6 Replies
View Related
Jul 23, 2010
I am facing one performance issue, in which the query cost is very low compare to cpu cost and as a result the cpu always show the high graph.I am also attaching the gv$sql and gv$sql_plan data of this query.
This is the query:
SELECT PTLS.ITEMTYPE , PTLS.ITEMID , PTLS.STAGEID, TS.USERID, SUM(PREVIOUSHOURS) AS PREVIOUSHOURS, MIN(STARTDATE) AS STARTDATE, MAX(STARTDATE) AS ENDDATE FROM PROJECTTIMELOGSSTAGE PTLS, PROJECTTIMESHEETITEM PTSI, TIMESHEET TS WHERE PTLS.PROJECTID = :B2 AND TS.TIMESHEETID = PTSI.TIMESHEETID AND TS.USERID = :B1 AND PTSI.TIMESHEETID = PTLS.TIMESHEETID AND PTSI.ITEMTYPE = PTLS.ITEMTYPE AND PTSI.ITEMID = PTLS.ITEMID AND (PTSI.ISPWFITEM = 'N' OR PTSI.ISPWFITEM IS NULL) AND PTLS.ITEMTYPE NOT IN ('OtherTsk','NewTsk','Loc','Glb') AND (PTLS.ITEMTYPE, PTLS.ITEMID ) IN (SELECT ITEMTYPE, ITEMID FROM PROJECTTIMELOGSSTAGE PTLS1 WHERE PTLS1.PROJECTID = :B2 AND PTLS1.TIMESHEETID = :B3 ) GROUP BY PTLS.ITEMTYPE, PTLS.ITEMID, PTLS.STAGEID, TS.USERID
View 17 Replies
View Related
Jun 3, 2013
what is oracle Cost-Based Optimizer? Any material easy to follow?
View 3 Replies
View Related
Aug 1, 2012
I've been experiencing strange Oracle behavior from time to time when using "explain plan". what could be the reason? (I'm going to create an Oracle ticket when I could find the cause...)
The total cost of a query was low (ex. ~500) while sub-parts of the query has high cost (ex. ~10000).I don't want to provide the query itself as the issue is observed for huge queries (like 2M characters!).The execution plan looks like this:
+- SELECT STATEMENT , ALL_ROWS, Cost 736
|
+--+- WINDOW SORT , Cost 736
|
[code]...
View 5 Replies
View Related
Aug 4, 2010
I am working on Tuning a Materialized view. I was getting an error saying ORA-12008: error in materialized view refresh path
ORA-12801: error signaled in parallel query server P002, instance hrms-stg-db01:HRSTG1 (1)
ORA-01652: unable to extend temp segment by 16 in tablespace TEMP1.
so i increased the temp size. I am trying out various hints to get it rectified. But i am not sure if i should go for less cost or less bytes.
View 1 Replies
View Related
Jan 22, 2009
how to reduce the cpu cost for a query at query level.
View 10 Replies
View Related
Aug 24, 2007
I'm wanting to create a query that will give me a summary of parts and labor from work orders. However there are three tables. work_order, parts, labor. Sometimes there will only be parts, sometimes just labor, or sometimes both. Well my query will only return results when they are on both. Sample query is below. Do I need to create a temp table to gather the data or is there a way to do this with a sub query.
select work_order.wono, sum(parts.cost), sum(labor.cost)
from work_order, parts, labor
where
work_order.wono = parts.wono and
work_order.wono = labor.wono
group by work_order.wono;
View 5 Replies
View Related
Mar 21, 2013
I have Following wjich takes some minutes to executes i want to be tune so this query Executes fast.
Query :
SELECT a.CHDR_EXCH_CD ,TMHR_EXCH_TM_CD,'S' Sec_type,
round(SUM (Decode(csdt_Depo_Typ,'I',(Cal_Scheme_Rate(csdt_rsm_code,TO_DATE(:P_DT_FR,'DD-MM-RR'),csdt_stsc_cd,csdt_scp_qty)*csdt_scp_qty)-
(Cal_Scheme_Rate(csdt_rsm_code,TO_DATE(:P_DT_FR,'DD-MM-
[Code]...
Explain Plan Result :
Plan
SELECT STATEMENT ALL_ROWS
Cost: 1,669 Bytes: 67 Cardinality: 1
15 HASH GROUP BY
Bytes: 67 Cardinality: 1
14 CONCATENATION
[Code].....
After i see result , no 4 in explain plan result gives TABLE ACCESS FULL . i want to be indexing on that how to do this..
This table MG_COLL_SCP_DTL have index like this
CREATE UNIQUE INDEX CSDT_PK ON MG_COLL_SCP_DTL
(CSDT_CHDR_TRANS_NUM, CSDT_PROD_TYP, CSDT_TRAN_SR_NO, CSDT_CHDR_CDTL_COLL_TYP, CSDT_CHDR_CDTL_COLL_TYP_CD,
CSDT_STSC_CD, CSDT_CHDR_CLNT_CD, CSDT_CHDR_CLNT_TM_CD)
[Code]....
How to Reduce cost ???
View 4 Replies
View Related
May 23, 2012
How to find out the database is using Cost based analyzer?
Currently database is set to ALL_ROWS.
SQL> show parameter optimizer_mode
NAME TYPE VALUE
------------------------------------ ----------- -----------
optimizer_mode string ALL_ROWS
SQL>
SQL>
View 3 Replies
View Related
Sep 1, 2010
For an query, cost was 16Lakhs and was taking 30min, I brought down the cost to 1.5lakhs, but still it is taking 30min.
There were many outer joins and same table has been Used(FROM clause) 5 times in the query. I have introduced WITH clause, and brought down the cost.
View 7 Replies
View Related
Mar 27, 2012
Following is the query on TPC-H schema.
explain plan for select
count(*)
from
orders,
lineitem
where
o_orderkey= l_orderkey.
The trace 10053 (as shown below) for this query shows nested loop join with Lineitem as outer table and Orders as inner table. It is effectively join on composite index (pk_lineitem) of Lineitem and unique index(Pk_orderkey) of Orders table. The cost calculation formula as given in the book as "outer table cost + cardinality of outer table * inner table cost " fails here. I am not able to understand this.
BASE STATISTICAL INFORMATION
***********************
Table Stats::
Table: LINEITEM Alias: LINEITEM
#Rows: 6001215 #Blks: 109048 AvgRowLen: 124.00
Column (#1): L_ORDERKEY(NUMBER)
AvgLen: 6.00 NDV: 1500000 Nulls: 0 Density: 6.6667e-07 Min: 1 Max: 6000000
[code]....
how the cost has been calculated. This does not follow the traditional nested loop cost formula as mentioned in the book.
View 7 Replies
View Related
May 27, 2011
I have to compare a string entered in a form with a series of English strings in back-end PL/SQL( using LIKE operator )
But it so happens, the string entered in the form is specific to the language used in the country. for ex. in Dutch, it is entered in Dutch language.
So on comparing, it fails as the PL/SQL compares it with English Strings.
View 4 Replies
View Related
Jan 31, 2010
FRM-40202: Field must be entered.I have a custom form,developed by someone few years ago. While doing a F11 (query-find) in this custom forms in Oracle application, I get the message FRM-40202 Field must be entered because I have some mandatory fields.Below are the steps I follow to reproduce this bug.
- Open custom form
- Enter data/values in all mandatory fields.
- save. It saved back in database.
- then CTRL+F11 to see all the records.
- Only first two records are showing in the screen.
- And "FRM-40202: Field must be entered." at the bottom.
View 12 Replies
View Related
Mar 13, 2013
I'm having some columns in my form with required_property set to yes. When I'm trying to query FRM-40202 appears.
View 3 Replies
View Related
May 24, 2010
I have a procedure wherein i'll only get country name as input parameter, how can i get Time Zone of the country entered.
View 12 Replies
View Related
Jul 19, 2011
I'm getting below error. how can we avoid this error?
ERROR: frm-40102 record must be entered or deleted first
View 4 Replies
View Related
Oct 21, 2013
I have a column named account_detail of data type Varchar2(70). I want to enforce a law such that all data being entered in this column is entered as
22 22 22 22
which means there is a space after every two digits. How do I achieve this through oracle forms, is there a way in the property pallette through which I can set it's property to reflect this change or should I do this with key-next-item.
View 2 Replies
View Related
Apr 23, 2008
how to retrieve values if user entered in Mixed case means (case insesitive)?
We don't have control when user enters values and it might be SMITH or Smith or smith or SmIth.
How can write the query to get this kind of mixed case data?
View -1 Replies
View Related
Feb 28, 2012
I'm trying to add a column in an existing form. I added a text item and defined it as a database item. When I tried to rename the item the message (frm-15500 valid and unique object name must be entered)appears, and therefore not able to exit the property Platte.
Is there a way I can exit the Platte and should I've first add the column to the data block and then rename in my form ?
View 1 Replies
View Related
Sep 29, 2011
I am making a field mandatory dynamially by set_item_property to Required Yes.So when i left it blank it is displaying the error Frm-40202, it's fine. But when i closing this error message by clicking on OK button to enter the field it was not allowing me to navigate into the field. The same error message is reopening.
View 2 Replies
View Related
Sep 30, 2010
I have two blocks, blockA and blockB, both from the same table which is tableX.
When I query from blockA and it has returned results, then I go to blockB and edit some data and save, there was no problem. But when I don't execute query from blockA or if the query returned zero results, then I go to blockB and edit some data then save, I got this error. THe cursor then go to blockA first item. So now I have to delete that empty row before saving.
View 6 Replies
View Related
Mar 22, 2011
I am getting an error whenever I attempt to save a record.My form has a number of none table data blocks and one database block. I have traced the program and only one commit_form is being entered and I keep getting the 40405 error.
I have attempted to trap in an form level on-error trigger but that doesn't fire for this error.
View 1 Replies
View Related
Apr 14, 2010
I got an error FRM-40202: Field must be entered. I did some modifications to Standard form by copying it. after that when I selected the first Email check box in the list and then selected the Email button which I created newly for that form.
View 1 Replies
View Related
Oct 24, 2011
Is it possible to ignore the sql command prompt and the command entered while spooling. I tried the to set echo off,term off and some more options but it did not work.
Example:
SQL> spool c: est.log
SQL> Prompt "This is a test"
"This is a test"
SQL> spool off;
The spool file has the following
SQL> Prompt "This is a test"
"This is a test"
SQL> spool off;
Is it possible to set some options so that the spool file only contains output.
"This is a test"
View 3 Replies
View Related
Jan 23, 2013
i have a field referring to a password and i need to hide the data input when entered for security purposes.
example if the user enters 1111 the form displays ****
View 3 Replies
View Related
Feb 4, 2011
After validating the SQL statemnet during creating a Custom folder in OracleBi Admin following Error displays. While the same query execute in toad successfully.
The Custom SQL entered is not a valid SQL statement - ORA-01031:Insufficeint Privileges
View 1 Replies
View Related