Query Check
Dear Experts..
Plz check this query. I created UDF for TAX details in Reports for Accounts. UDF are running well. Then created Report for same. But the UDF VAlue is not retrieving in Report.
*SELECT T0.[DocNum], T0.[CardCode] As 'Vendor Code',T0.[CardName] As 'Vendor Name', T0.[NumAtCard] As 'Vendor Ref. No.', T0.[DocDate], T0.[TaxDate], T0.[DocTotal] - T0.[VatSum] As 'Basic Value of Goods', T0.[U_CENVAT] As 'CENVAT', T0.[U_ECess], T0.[U_HSCess], T0.[U_VAT_4], T0.[U_Add_VAT1], T0.[U_VAT_12],
T0.[U_Add_VAT2], T0.[U_CST2], T0.[U_CST4], T0.[U_CST5], T0.[U_Service_Tax], T0.[U_ST_ECess], T0.[U_ST_HSCess],T0.[TotalExpns] As 'Others',T0.[DocTotal] - T0.[VATSUM] As 'Total' FROM OPCH T0 WHERE T0.[docType] = 'I' and T0.[TaxDate] Between [%0] And [%1]*
Plz make changes in query if need.
Thanks in Advance.
Regards,
Ravi
Hi,
try below,
SELECT T0.DocNum, T0.CardCode As 'Vendor Code',T0.CardName As 'Vendor Name', T0.NumAtCard As 'Vendor Ref. No.', T0.DocDate, T0.TaxDate, T0.DocTotal - T0.VatSum As 'Basic Value of Goods', T0.U_CENVAT As 'CENVAT', T0.U_ECess, T0.U_HSCess, T0.U_VAT_4, T0.U_Add_VAT1, T0.U_VAT_12,
T0.U_Add_VAT2, T0.U_CST2, T0.U_CST4, T0.U_CST5, T0.U_Service_Tax, T0.U_ST_ECess, T0.U_ST_HSCess,T0.TotalExpns As 'Others',T0.DocTotal - T0.VATSUM As 'Total' FROM OPCH T0 WHERE T0.docType = 'I' and (T0.TaxDate >= %0 And T0.TaxDate<=%1)
Regards
Deepak tyagi
Similar Messages
-
Hi All,
I am currently trying to create a table (TOPIC) and a sequence (SEQ_TOPIC_ID) in HCP, and a XSJS service on top of it to insert a entry to the table.
In my XS project, I placed a TOPIC.hdbtable and SEQ_TOPIC_ID.hdbsequence in it. Both table and sequence are generated correctly in my trial account schema in the hana db.
Then,in order to grant the access to the table and sequence , I also placed a file model_access.hdbrole in the project folder.
The content looks like follow:
role i065831trial.bubuwork.TopicCenter::model_access {
application privilege: i065831trial.bubuwork.TopicCenter::Basic;
sql object i065831trial.bubuwork.TopicCenter::TOPIC : SELECT,INSERT;
sql object i065831trial.bubuwork.TopicCenter::SEQ_TOPIC_ID : SELECT, DROP;
The issue is, when I call the XSJS service from the web url, I will facing below error:
Error while executing query: [dberror(Connection.prepareStatement): 258 - insufficient privilege: Not authorized at ptime/query/checker/query_check.cc:2547]
the role has been granted to my account, and I am able to insert to the table TOPIC without sequence with above role setting, but If I try to read the SEQ_TOPIC_ID, an insufficient privilege will shown up.
My question is: Is following line correct to grant the privilege to a role for sequence ? It does not seem to work for sequence !
sql object i065831trial.bubuwork.TopicCenter::SEQ_TOPIC_ID : SELECT, DROP;
Thanks very much!Thanks Thomas for your reply, firstly I tried to embed my sequence in the insert SQL, as the problem happened. I pulled out the sequence into a single query string, like blow:
var select_topic_next_val = "select \"i065831trial.bubuwork.TopicCenter::SEQ_TOPIC_ID\".nextval as seqid from dummy";
function close(closables) {
var closable;
var i;
for (i = 0; i < closables.length; i++) {
closable = closables[i];
if(closable) {
closable.close();
function insertTopic(xargs){
var connection = $.db.getConnection();
var statement = null;
var resultSet = null;
try{
//get next sequence id
statement = connection.prepareStatement(select_topic_next_val);
resultSet = statement.executeQuery();
while(resultSet.next()){
var seqId = resultSet.getString(1);
break;
// statement = connection.prepareStatement(insert_topic_sql);
// statement.setString(1,seqId);
// statement.setString(2,xargs.owner);
// statement.setString(3,xargs.approver);
// statement.setString(4,xargs.name);
// statement.setString(5,xargs.status);
// statement.setString(6,xargs.description);
// //statement.setTimestamp(6,xargs.lastModify);
// statement.setTimestamp(7,null);
// statement.setDate(8,xargs.begda);
// statement.setDate(9,xargs.endda);
// statement.setString(10,xargs.keyword);
// statement.executeUpdate();
}finally {
close([resultSet, statement, connection]); -
I have a discover report which have 5 union all, and one of the select statement brings the information about the cr.type like 'MISC'from the table called ar.ar_cash_receipts_all cr.
This query basically brings the information of amount_dr and amount_Cr from the general ledger table, the navigation for the same is as below.
Navigation:
Enter journals
pick some Batch Name
Click find button
Place cursor on the line item from the list that has Journal Name like Miscellaneous receipts
Click on Review Journal.
When you check the record history pulls the information as GL_JE_LINES_V.
I am not able to pick few of my amount_cr values.
Tables and joints used for my query is as below.
Please correct me if i am missing any information.
Thanks in advance.
Archice
APPS.ra_customer_trx_all ct
,AR.ra_cust_trx_types_all ctt
,AR.ar_distributions_all ard
,apps.hz_cust_accounts_all cust
,AR.hz_parties cust2
,AR.ar_adjustments_all adj
,GL.gl_sets_of_books books
where
adj.set_of_books_id=books.set_of_books_id) and
nvl(adj.postable,'Y')='Y') and
adj.adjustment_id=ard.source_id) and
ard.source_table='ADJ') and
adj.customer_trx_id=ct.customer_trx_id)
and ctt.cust_trx_type_id=ct.cust_trx_type_id) and
cust.cust_account_id=decode(ctt.type,'BR',ct.drawee_id,ct.bill_to_customer_id)) and
cust2.party_id=cust.party_id and
ctt.set_of_books_id=books.set_of_books_id(+)Hi Blushadow,
Thanks for responding my query, here is best i can mention further regarding my query problem.
The code which I have posted earlier, has been coded by some other technical person, I have posted part of the main query which pulls ‘MISC’, the posted query is not pulling all the amount_credit (amount_cr) column information, few of the lines are missing,
The amount_dr, amount_cr is basically called form GL_JE_LINES_V, I have checked this from record history, I want to know whether, I need any further tables to be added for the existing query, in order to pull the missing amount_cr
Lines.
Basically, when we check the description of the view GL_JE_LINES_V
We have few tables.
GL_JE_LINES JEL
, GL_CODE_COMBINATIONS CC
, GL_JE_LINES_RECON REC
, GL_SYSTEM_USAGES USE
I would like to know is there any way to use another table instead of
GL_JE_LINES_RECON REC, because when I query it, I wont see any data from this table and this have two major joins in the mentioned view called GL_JE_LINES_V.
Regards
Archie -
SELECT QUERY CHECK & WHERE CLAUSE DIFFERENCE.URGENT PLEASE.
My question is ,
IF SBOOK_WA-CARRID = 'LH' CONDITION IS AGAIN PRESENT IN THE DATABASE TABLE ,,,,WILL THE CHECK CONDITION SEARCH IT AGAIN EVEN AFTER FINDING IT IN THE FIRST OF THE TABLE???OR SIMPLY TERMINATE IN THE FIRST TIME THE CONDITION SATISFIES??IF DOES TERMINATE THEN ERRONEOUS RESULT IS BOUND TO COME SINCE ONE MORE RECORS IS UNSELECTED.
SIMILARLY DOES THE WHERE CLAUSE CONTINUE SEARCHING EVEN AFTER HAVING FOUND THE CONDITION ALREADY ONCE IN THE TABLE??
PLEASE HELP ME IN THIS ASPECT.PLEASE CHECK THE TWO DIFFERENT CODES & ANSWER ACCORDINGLY..
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.
SELECT * FROM SBOOK INTO SBOOK_WA
WHERE CARRID = 'LH' AND
CONNID = '0400'.
ENDSELECT.Hi,
The Check condition will be true, so it will not going to display the records, it will fill the internal table.
In the Where condition it will fill the Internal table as well as it will display also.
Hope now your query is solved
Regards,
Dhruv Shah -
Simple mysql query Check in database
Basically I'm just trying to chekc whether the user exists on the database.
Mysql Table has - name user, pass...
My servlet is issuing query - String sql = "SELECT * FROM users WHERE username'"+user'";
ResultSet rs = stmt.executeQuery(sql);
Question - how do i check if the query's result.
Simple user authentication via database. Sorry but im new to Java
Pls helpMysql Table has - name user, pass...
My servlet is issuing query - String sql = "SELECT *
FROM users WHERE username'"+user'";Does this query work?
ResultSet rs = stmt.executeQuery(sql);
Question - how do i check if the query's result.
Simple user authentication via database. Sorry but
im new to JavaFor the simplest authentication, I would use
SELECT count(*) FROM users WHERE username = '<user>' and password = '<password>'
To read through the resultset for this query:
if(rs.next() && rs.getInt(1) > 0) {
System.out.println("User validated");
} else {
System.out.println("User credentials do not match");
}What you need is http://java.sun.com/docs/books/tutorial/jdbc/ -
Basic query - check oracle server install type
How do I check if the Oracle 10g is configured as GENERAL_PURPOSE or TRANSACTION_PROCESSING or DATAWAREHOUSE?
I searched the forums but did not find anything specific for this info. This is an existing installation, I cant find the the installation log which will have this type of information. I am wondering if there are any parameters which can be looked at to determine the type or Oracle Configuration. Any tips - thanks.rman_guru wrote:
How do I check if the Oracle 10g is configured as GENERAL_PURPOSE or TRANSACTION_PROCESSING or DATAWAREHOUSE?
I searched the forums but did not find anything specific for this info. This is an existing installation, I cant find the the installation log which will have this type of information. I am wondering if there are any parameters which can be looked at to determine the type or Oracle Configuration. Any tips - thanks.There really is no specific setting of the database that makes it any of the above. Choosing one of those templates will select certain SGA parameters to have different values that are 'best guess' optimized for particular database usage. But even those are just starting points and -- like I said -- best guesses.
What business problem are you trying to solve. Assuming your question had the kind of answer you anticipated when posting this, what decision is riding on the outcome? -
Report or Query, check for Visio versions - Standard, Professional, etc?
Hi,
Just wondering if anyone knows a good method with 2012 of reporting on versions of Visio - e.g. Professional, Standard, Premium etc. I can't seems to find the breakdown anyway.
I've seen similar queries created for ConfigMrg 2007 Reports, but with the 2012 Report Builder, its not so straightforward to copy and paste a SQL query in (I've tried successfully creating other reports, via "the "edit as text" button, but
no luck with this sort of report).
Any help greatly appreciated!
Thanks.http://social.technet.microsoft.com/Forums/office/en-US/07a859bb-d1c8-49a7-8f4c-bcf81b887221/how-can-i-tell-if-visio-standard-or-pro-are-installed?forum=visiogeneral
if key
HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Visio\Solution\UML Solution
exists then you have Visio Pro. -
How do I check for null parameters in Process Validations?
I am trying to create a Unit Test that validates that a record has been inserted into a table. However I am having problems when dealing with null parameters.
I created a simple table and insert procedure:
create table TEST_TAB (
A varchar2 (30) not null,
B varchar2 (30));
create or replace procedure TEST_TAB_INS (P_A in varchar2, P_B in varchar2) is
begin
insert into TEST_TAB values (P_A, P_B);
end;
Then I created a Unit Test with two implementations:
The first executes TEST_TAB_INS ('One', 'Two')
The second executes TEST_TAB_INS ('One', null)
I attached the following Query Returning Rows Process Validation to both implementations:
select *
from TEST_TAB
where A = '{P_A}'
and (B = '{P_B}' or '{P_B}' is null)
This should allow for the case where P_B is null. However the second test fails with a "Query check returned no rows" error.
I've tried altering the test to use nvl, but get the same results:
select *
from TEST_TAB
where A = '{P_A}'
and (B = '{P_B}' or nvl ('{P_B}', 'XXXX') = 'XXXX')
However, the following test succeeds:
select *
from TEST_TAB
where A = '{P_A}'
and (B = '{P_B}' or nvl ('{P_B}', 'XXXX') = '{P_B}')
Which suggests that null parameters are not being treated as nulls in Process ValidationsI've found a way to solve this. By changing the test to:
select *
from TEST_TAB
where A = '{P_A}'
and (B = '{P_B}' or '{P_B}' = 'NULL')
I am able to get both to get both implementations to succeed.
Edited by: AJMiller on Dec 28, 2012 4:24 AM -
Analysis Authorization : Selection screen not appearing for query
Hi,
I am facing an issue with analysis authorization. I have created the new roles and assigned to the users. For one user when I am executing the query, the selection screen is not coming up and it shows error message to specify the variables. Whereas its running for all other users.
In S_RS_COMP I have selected Type of a reporting component as Query View, Query & Template structure. I also tried adding Variable in this field but that also did not help.
Please let me know if you have faced similar issue.
Regards,
ManishHi,
Go to your query desinger opend your query and select your variable in that you have see first "Ready Input Query" Check box is selected or not. It's not selected you can select that check box.
Your problem will be sloved.
Thanks & Regards,
venkat. -
Insert result of query into a table with unique constraint
Hi,
I have a query result that I would like to store in a table. The target table has a unique constraint. In MySQL you can do
insert IGNORE into myResultTable <...select statement...>
The IGNORE clause means if inserting a row would violate a unique or primary key constraint, do not insert the row, but continue inserting the rest of the query. Leaving the IGNORE clause out would cause the insert to fail and an error to return.
I would like to do this in oracle... that is insert the results of a query that are not already in the target table. What is the best way to do this? One way is use a procedural language and loop through the first query, checking to see if each row is a duplicate before inserting it. I would think this would be slow if there are lots of records. Other options...
insert into myTargetTable
select value from mySourceTable where ... and not exists (select 'x' from myTargetTable where value = mySourceTable.value)
insert into myTargetTable
select mySourceTable.value
from myTargetTable RIGHT JOIN mySourceTable
ON myTargetTable.value = mySourceTable.value
where ...
and myTargetTable.value IS NULL
any other suggestions?
Thanks,
SimonTry doing a MINUS instead of not exists., ie Source MINUS Target.
Disabling the constraint will not help you since this will allow the duplicate rows to be inserted into the table. I don't think you want this.
--kalpana -
Hi
I have Pure SQL DataBase name of Table as per given Coloumn Name.
User Name StartDate EndDate
Mr.Jack 01/04/2010 05/04/2010
Mr.Perlin 07/04/2010 10/04/2010
Mr.Tinklin 01/05/2010 05/05/2010
Mr.Kerlin 12/04/2010 15/04/2010
Now I am using asp.net Form Using C#...
Name --> TextBox
StartDate -> TextBox
EndDate --> TextBox
Now User enter the Dates after Click Save Button....
Here SQL Query Check Whether the User Dates Clause into Data Base Date's.
For Examble..
User Enter Start Date = 04/04/2010, EndDate =08/04/2010
Now Query it check SQL DataBase, Already 01/04/2010 to 10/04/2010 Available so Dont allow Save.... only allow various dates...
---------------- This is task Condition -------
i am using SQL Query
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate ='02/04/2010' --// This is User Start Date coming from Text Box
SET @EndDate = '10/04/2010' --// This is User End Date coming from Text Box
IF NOT EXISTS (SELECT PollID FROM Polls WHERE (StartDate<= CAST (CONVERT(VARCHAR,@StartDate,101) AS DATETIME) OR EndDate <= CAST (CONVERT (VARCHAR,@EndDate,101) AS DateTime)) AND STATUS<>'D')
SELECT 'OK ALLLOW'
ELSE
SELECT 'NOT ALLOW'
But it is not working Correctly....
Pls give some correctful query for solve task Condition
By
Riyaz
Edited by: 798225 on Sep 28, 2010 10:37 PM
Edited by: 798225 on Sep 28, 2010 10:52 PMNow I am developing Polls Application in asp.net
I am using Polls Concept,
DateBase Name : Polls
Fields : PollID PollName StartDate EndDate UserID
In Asp.Form Having
User Name : TextBox
PollName: TextBox
StartDate: TextBox
EndDate: TextBox
Submit - Button
Task Details
Whenever User Click after fillup all data's... then SQL Query Check
if StartDate or EndDate is exists in Between DataBase Date's.....
Condition true means dont allow save.. else Save.....
Examble:
PollID PollName StartDate EndDate UserName
01 Sample 23/09/2010 26/09/2010 Klit
02 Sample 2 29/09/2010 30/09/2010 Jack
Now User given follwing details and click Submit,
User Name : James
PollName: Test
StartDate: 22/09/2010
EndDate: 27/09/2010
Submit - Button
Here User StartDate: 22/09/2010 , EndDate: 27/09/2010
SQL Query Check ,
Condtion 1 : Those dates are avilable in Datebase???
Result: Yes
Because, Sample Poll date is 23/09/2010 to 26/09/2010, here Start Date is Not Exists, But End Date Exists.
So dnt allow Save Operation....
Now User Again given follwing details and click Submit,
User Name : James
PollName: Test
StartDate: 27/09/2010
EndDate: 28/09/2010
Submit - Button
Here User StartDate: 27/09/2010 , EndDate: 28/09/2010
SQL Query Again Check ,
Condtion 1 : Those dates are avilable in Datebase???
Result: No
Because, Sample Poll date is 23/09/2010 to 26/09/2010,
Sample1 Poll Date is 29/09/2010 to 30/09/2010
here Start Date is Not Exists, But End Date Not Exists.
So Allow Save Operation....
This a My Task....
Could You give SQL Query for help to Check given condition??
regd
Riayz
Edited by: Riyaz on Sep 30, 2010 1:08 AM -
Parse SQL: How to extract column names, table names from a SQL query
Hi all,
I have a requirement wherein a SQL query will be given in a text file.
The text file has to be read (probably using text_io package), the SQL query needs to be parsed and the column names, table names and where clauses have to be extracted and inserted into separate tables.
Is there a way to do it using PL/SQL ?
Is there a PL/SQL script available to parse and extract column names, table names etc ?
Pls help.
Regards,
SamI think I jumped to conclusion too early saying it is completely possible and straight forward. But after reading through your post for one more time I realised you are not interested only in the column_names, also the table_names and the predicates .
>
SQL query needs to be parsed and the column names
>
The above is possible and straight forward using the dbms_sql package.
I am pasting the same information as I did in the other forum.
Check this link and search for Example 8 and .
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#sthref6136
Also check the working example from asktom
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1035431863958
>
table names and where clauses have to be extracted
>
Now this is the tricky bit. You can extract the list of tables by getting the sql_id from v$sql and joining it with v$sql_plan. But sometimes you may not get all the results because the optimizer may choose to refine your query (check this link)
http://optimizermagic.blogspot.com/2008/06/why-are-some-of-tables-in-my-query.html
and you can get the predicate information from the same table v$sql_plan but I will leave that area for you to do some R&D.
Regards
Raj
Edited by: R.Subramanian on Dec 10, 2008 3:14 AM -
Using SAP BEx to create query error
After query creation in excel, shown 'No Applicable Data Found'. Who can help to solve this problem. Thanks in advance.
HI,
At first, U should check your InfoProvider in the BI system to confirm that are there any record in your InfoProvider.
If above is true, then you should check your filters and restrictions in your query, check it in query desinger. Particularly check the variants for limitation, becase this is globally.
Hope this helps.
Bob
Message was edited by:
Bob -
Hello,
When I Start the Query, I want to choose. For Expample:
For Display the Query with the Rows or not....
1.Button with Film Production
2.Button without Film Production
Can I realize 2 Buttons for that ?`??
Thanks and Happy Easter..
Barish
Edited by: Baris Ozcan on Mar 19, 2008 8:12 AMHi,
Selections means... your column or row.
In 7.0 QD .Select your keyfigure from column. right side you can see property window. where you have tab "Display". check that whether it should be "Always show". if it is there, definitely the keyfigure will show the result. and also, if you are not getting any output value, when u r executing the query. check that any filter have u used in Query..
might be ur query restriction doesn't give any value, that's y ur report looks empty.
note: there is no Query change mode in BI7.0 query designer, as we have in bw3.5.
Regards,
senthil -
Query performance tuning need your suggestions
Hi,
Below is the sql query and explain plan which is taking 2 hours to execute and sometime it is breaking up( erroring out) due to memory issue.
Below it the query which i need to improve the performance of the code please need your suggestion in order to tweak so that time take for execution become less and also in less memory consumption
select a11.DATE_ID DATE_ID,
sum(a11.C_MEASURE) WJXBFS1,
count(a11.PKEY_GUID) WJXBFS2,
count(Case when a11.C_MEASURE <= 10 then a11.PKEY_GUID END) WJXBFS3,
count(Case when a11.STATUS = 'Y' and a11.C_MEASURE > 10 then a11.PKEY_GUID END) WJXBFS4,
count(Case when a11.STATUS = 'N' then a11.PKEY_GUID END) WJXBFS5,
sum(((a11.C_MEASURE ))) WJXBFS6,
a17.DESC_DATE_MM_DD_YYYY DESC_DATE_MM_DD_YYYY,
a11.DNS DNS,
a12.VVALUE VVALUE,
a12.VNAME VNAME,
a13.VVALUE VVALUE0,
a13.VNAME VNAME0,
9 a14.VVALUE VVALUE1,
a14.VNAME VNAME1,
a15.VVALUE VVALUE2,
a15.VNAME VNAME2,
a16.VVALUE VVALUE3,
a16.VNAME VNAME3,
a11.PKEY_GUID PKEY_GUID,
a11.UPKEY_GUID UPKEY_GUID,
a17.DAY_OF_WEEK DAY_OF_WEEK,
a17.D_WEEK D_WEEK,
a17.MNTH_ID DAY_OF_MONTH,
a17.YEAR_ID YEAR_ID,
a17.DESC_YEAR_FULL DESC_YEAR_FULL,
a17.WEEK_ID WEEK_ID,
a17.WEEK_OF_YEAR WEEK_OF_YEAR
from ACTIVITY_F a11
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 1 ) a12
on (a11.PKEY_GUID = a12.PKEY_GUID and
a11.DATE_ID = a12.DATE_ID and
a11.ORG = a12.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 2) a13
on (a11.PKEY_GUID = a13.PKEY_GUID and
a11.DATE_ID = a13.DATE_ID and
a11.ORG = a13.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 3 ) a14
on (a11.PKEY_GUID = a14.PKEY_GUID and
a11.DATE_ID = a14.DATE_ID and
a11.ORG = a14.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 4) a15
on (a11.PKEY_GUID = a15.PKEY_GUID and
89 a11.DATE_ID = a15.DATE_ID and
a11.ORG = a15.ORG)
join (SELECT A.ORG as ORG,
A.DATE_ID as DATE_ID,
A.TIME_OF_DAY_ID as TIME_OF_DAY_ID,
A.DATE_HOUR_ID as DATE_HOUR_ID,
A.TASK as TASK,
A.PKEY_GUID as PKEY_GUID,
A.VNAME as VNAME,
A.VVALUE as VVALUE
FROM W_ORG_D A join W_PERSON_D B on
(A.TASK = B.TASK AND A.ORG = B.ID
AND A.VNAME = B.VNAME)
WHERE B.VARIABLE_OBJ = 9) a16
on (a11.PKEY_GUID = a16.PKEY_GUID and
a11.DATE_ID = a16.DATE_ID and
A11.ORG = A16.ORG)
join W_DATE_D a17
ON (A11.DATE_ID = A17.ID)
join W_SALES_D a18
on (a11.TASK = a18.ID)
where (a17.TIMSTAMP between To_Date('2001-02-24 00:00:00', 'YYYY-MM-DD HH24:MI:SS') and To_Date('2002-09-12 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
and a11.ORG in (12)
and a18.SRC_TASK = 'AX012Z')
group by a11.DATE_ID,
a17.DESC_DATE_MM_DD_YYYY,
a11.DNS,
a12.VVALUE,
a12.VNAME,
a13.VVALUE,
a13.VNAME,
a14.VVALUE,
a14.VNAME,
a15.VVALUE,
a15.VNAME,
a16.VVALUE,
a16.VNAME,
a11.PKEY_GUID,
a11.UPKEY_GUID,
a17.DAY_OF_WEEK,
a17.D_WEEK,
a17.MNTH_ID,
a17.YEAR_ID,
a17.DESC_YEAR_FULL,
a17.WEEK_ID,
a17.WEEK_OF_YEAR;
Explained.
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 1245 | 47 (9)| 00:00:01 |
| 1 | HASH GROUP BY | | 1 | 1245 | 47 (9)| 00:00:01 |
|* 2 | HASH JOIN | | 1 | 1245 | 46 (7)| 00:00:01 |
|* 3 | HASH JOIN | | 1 | 1179 | 41 (5)| 00:00:01 |
|* 4 | HASH JOIN | | 1 | 1113 | 37 (6)| 00:00:01 |
|* 5 | HASH JOIN | | 1 | 1047 | 32 (4)| 00:00:01 |
|* 6 | HASH JOIN | | 1 | 981 | 28 (4)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 915 | 23 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 1 | 763 | 20 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1 | 611 | 17 (0)| 00:00:01 |
| 10 | NESTED LOOPS | | 1 | 459 | 14 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 1 | 307 | 11 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 1 | 155 | 7 (0)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 72 | 3 (0)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID| W_SALES_D | 1 | 13 | 2 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | CONS_UNQ_W_SALES_D_SRC_ID | 1 | | 1 (0)| 00:00:01 |
| 16 | TABLE ACCESS BY INDEX ROWID| W_DATE_D | 1 | 59 | 1 (0)| 00:00:01 |
|* 17 | INDEX UNIQUE SCAN | UIDX_DD_TIMSTAMP | 1 | | 0 (0)| 00:00:01 |
| 18 | TABLE ACCESS BY INDEX ROWID | ACTIVITY_F | 1 | 83 | 4 (0)| 00:00:01 |
|* 19 | INDEX RANGE SCAN | PK_ACTIVITY_F | 1 | | 3 (0)| 00:00:01 |
|* 20 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 4 (0)| 00:00:01 |
|* 21 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 22 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 23 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 24 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 25 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 26 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 27 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 28 | TABLE ACCESS BY INDEX ROWID | W_ORG_D | 1 | 152 | 3 (0)| 00:00:01 |
|* 29 | INDEX RANGE SCAN | IDX_FK_CVSF_PKEY_GUID | 10 | | 3 (0)| 00:00:01 |
|* 30 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 31 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 32 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 33 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
|* 34 | TABLE ACCESS FULL | W_PERSON_D | 1 | 66 | 4 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------------------------------Hi,
I'm not a tuning expert but I can suggest you to post your request according to this template:
Thread: HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting
Then:
a) you should posting a code which is easy to read. What about formatting? Your code had to be fixed in a couple of lines.
b) You could simplify your code using the with statement. This has nothing to do with the tuning but it will help the readability of the query.
Check it below:
WITH tab1 AS (SELECT a.org AS org
, a.date_id AS date_id
, a.time_of_day_id AS time_of_day_id
, a.date_hour_id AS date_hour_id
, a.task AS task
, a.pkey_guid AS pkey_guid
, a.vname AS vname
, a.vvalue AS vvalue
, b.variable_obj
FROM w_org_d a
JOIN
w_person_d b
ON ( a.task = b.task
AND a.org = b.id
AND a.vname = b.vname))
SELECT a11.date_id date_id
, SUM (a11.c_measure) wjxbfs1
, COUNT (a11.pkey_guid) wjxbfs2
, COUNT (CASE WHEN a11.c_measure <= 10 THEN a11.pkey_guid END) wjxbfs3
, COUNT (CASE WHEN a11.status = 'Y' AND a11.c_measure > 10 THEN a11.pkey_guid END) wjxbfs4
, COUNT (CASE WHEN a11.status = 'N' THEN a11.pkey_guid END) wjxbfs5
, SUM ( ( (a11.c_measure))) wjxbfs6
, a17.desc_date_mm_dd_yyyy desc_date_mm_dd_yyyy
, a11.dns dns
, a12.vvalue vvalue
, a12.vname vname
, a13.vvalue vvalue0
, a13.vname vname0
, a14.vvalue vvalue1
, a14.vname vname1
, a15.vvalue vvalue2
, a15.vname vname2
, a16.vvalue vvalue3
, a16.vname vname3
, a11.pkey_guid pkey_guid
, a11.upkey_guid upkey_guid
, a17.day_of_week day_of_week
, a17.d_week d_week
, a17.mnth_id day_of_month
, a17.year_id year_id
, a17.desc_year_full desc_year_full
, a17.week_id week_id
, a17.week_of_year week_of_year
FROM activity_f a11
JOIN tab1 a12
ON ( a11.pkey_guid = a12.pkey_guid
AND a11.date_id = a12.date_id
AND a11.org = a12.org
AND a12.variable_obj = 1)
JOIN tab1 a13
ON ( a11.pkey_guid = a13.pkey_guid
AND a11.date_id = a13.date_id
AND a11.org = a13.org
AND a13.variable_obj = 2)
JOIN tab1 a14
ON ( a11.pkey_guid = a14.pkey_guid
AND a11.date_id = a14.date_id
AND a11.org = a14.org
AND a14.variable_obj = 3)
JOIN tab1 a15
ON ( a11.pkey_guid = a15.pkey_guid
AND a11.date_id = a15.date_id
AND a11.org = a15.org
AND a15.variable_obj = 4)
JOIN tab1 a16
ON ( a11.pkey_guid = a16.pkey_guid
AND a11.date_id = a16.date_id
AND a11.org = a16.org
AND a16.variable_obj = 9)
JOIN w_date_d a17
ON (a11.date_id = a17.id)
JOIN w_sales_d a18
ON (a11.task = a18.id)
WHERE (a17.timstamp BETWEEN TO_DATE ('2001-02-24 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND TO_DATE ('2002-09-12 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND a11.org IN (12)
AND a18.src_task = 'AX012Z')
GROUP BY a11.date_id, a17.desc_date_mm_dd_yyyy, a11.dns, a12.vvalue
, a12.vname, a13.vvalue, a13.vname, a14.vvalue
, a14.vname, a15.vvalue, a15.vname, a16.vvalue
, a16.vname, a11.pkey_guid, a11.upkey_guid, a17.day_of_week
, a17.d_week, a17.mnth_id, a17.year_id, a17.desc_year_full
, a17.week_id, a17.week_of_year;
{code}
I hope I did not miss anything while reformatting the code. I could not test it not having the proper tables.
As I said before I'm not a tuning expert nor I pretend to be but I see this:
1) Table W_PERSON_D is read in full scan. Any possibility of using indexes?
2) Tables W_SALES_D, W_DATE_D, ACTIVITY_F and W_ORG_D have TABLE ACCESS BY INDEX ROWID which definitely is not fast.
You should provide additional information for tuning your query checking the post I mentioned previously.
Regards.
Al
Maybe you are looking for
-
Ok I don't know why in the world everyone else has access to the App Store and almost anything they want. Guess what I have access to? Yea that's right I have access to nothing that they have! I believe that their iPads are glitching and that might b
-
i dented my brand new Ipad, will Apple cover this under its Warranty, I found on You tube that Apple replaced the dented Ipad of a user with a brand new Ipad
-
ITunes stopped organizing music folder
I have iTunes set to organize music. All of a sudden, when I put a tune into the music folder and click it, it appears in iTunes and plays, but a new folder is not created and it stays in the main folder. In the Preferences screen, Advanced, General
-
Need help bad. Installed new HD and I dont want to lose my music on ipod
Can someone please help I had a HD crash and had to install a new HD. but when I plug my ipod into my computer it is telling me I have to reformat. I have allot of songs I purchsed and I dont want to lose them. Is there a way to transfer playlists an
-
What to buy? - G5 or Intel ? ?
Daughter #1 needs a new computer so I'm giving her my 1 year old iMac G5 17" 1.8 ghz. That means I can upgrade to a 20" iMac. I'm torn about buying an iMac Intel or a 2.1 ghz G5. Outside of the iLife suite, Safari and Mail, I use the iMac with Office