Issue with query using minus operation
Hello All,
I have data set of all organization numbers like as below
Dataset:
('528801','528802','536101','536102','100601','536401','536402','530701','536501','536502','540501','599101','133301',
'531101','143101','536601','536602','534401','535501','535401','536801','536802','531001','537501','537502','540601','540801','528401')
And i also have a table W_INT_ORG_D where in it has column like ORG_NUM which holds the organization numbers in the database, now i am trying to find out the exclusive organization numbers in the data set that does not exist in W_INT_ORG_D using some oracle sql query.
Below is the sql i wrote though my query is wrong probably you could able to understand what i am trying to say or achieve, i am not ok with creating another table and filling in the data and later compare both tables, i want to do that without creating any extra table. Please let me know if you have any idea to do this, appreciate your time.
Query:_
WITH ABC AS
('528801','528802','536101','536102','100601','536401','536402','530701','536501','536502','540501','599101','133301',
'531101','143101','536601','536602','534401','535501','535401','536801','536802','531001','537501','537502','540601','540801','528401')
SELECT DISTINCT ORG_NUM
FROM W_INT_ORG_D, ABC
WHERE DATASOURCE_NUM_ID='211'
AND ORG_NUM IN
('528801','528802','536101','536102','100601','536401','536402','530701','536501','536502','540501','599101','133301',
'531101','143101','536601','536602','534401','535501','535401','536801','536802','531001','537501','537502','540601','540801','528401')
MINUS
SELECT * FROM ABC
Thanks,
Sam
This wil give a list of organization numbers in dataset that are not present in the view:
SELECT column_value org_num
FROM TABLE(sys.odciVarchar2List(
'528801',
'528802',
'536101',
'536102',
'100601',
'536401',
'536402',
'530701',
'536501',
'536502',
'540501',
'599101',
'133301',
'531101',
'143101',
'536601',
'536602',
'534401',
'535501',
'535401',
'536801',
'536802',
'531001',
'537501',
'537502',
'540601',
'540801',
'528401'
MINUS
SELECT DISTINCT ORG_NUM
FROM W_INT_ORG_D
WHERE DATASOURCE_NUM_ID='211'
/SY.
Edited by: Solomon Yakobson on Jun 29, 2009 10:49 AM
Similar Messages
-
Issues with query using joins in 3 tables
I am trying to fetch data from 3 tables (Project,RIsk and Issues) using join. There are Risks associated with some projects and Issues associated with some projects.
ProjectID is primary key in Project table.
RiskID is primary key in risk table. ProjectID is foreign key.
IssueID is primary key in Issue table.ProjectID is foreign Key.
I need the projectname, count of risks for projects, count of issues for projects. I am using joins in all the 3 tables. Issue here is, its giving me double of count of risks and issues for each project.
Please advise how can I get the correct number. I have used the below query,
select p.projectname,count(r.riskid),count(i.issueid) from project as p
left outer join risk as r on p.projectid=r.projecctid
left outer join issue as i on p.projectid=i.projectid
group by
p.projectname
thanksHi All,
I got a new requirement to count, the number of high priority risks as well as high priority issues along with the other details. I modified the below table to include the changes, but I am not getting the desired result. Could you please help?
Original query:
select p.projectname,count(distinct r.riskid), count(distinct i.issueid) from project as p
left outer join risk as r on p.projectid=r.projecctid
left outer join issue as i on p.projectid=i.projectid
group by p.projectname
Modified query:
select p.projectname,count(distinct r.riskid),sum(case when r.riskpriority='high' then 1 else 0 end), sum(case when i.issuepriority='high' then 1 else 0 end),count(distinct i.issueid) from project as p
left outer join risk as r on p.projectid=r.projecctid
left outer join issue as i on p.projectid=i.projectid
group by p.projectnameI should get the desired result as:XYZ,8,1,4,4But I am getting:XYZ,8,4,4,32thanks for the reply. -
How to write the given query using 'ANY ' operator
Hi,
How to write the given query using 'ANY ' operator , I dont need to fetch to grade_master table twice in database, just need to fetch within the result set.
SELECT dsg_code,dsg_name,dsg_grade FROM designation_master WHERE dsg_orgn='&&Orgn' and dsg_ctry='&&ctry'
And dsg_loc ='&&loc' And dsg_oru = '&&oru' and dsg_grade in decode('&&radio_group',
1, SELECT grd_code FROM grade_master WHERE grd_osm_code in (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&Orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'),
2, SELECT grd_code FROM grade_master WHERE grd_osm_code > (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code),
3, SELECT grd_code FROM grade_master WHERE grd_osm_code < (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'))
thanks
rincyHi,
One thing I understood my your issue is you want to perform, execution of query once or fetch the results sets my minimizing the number of times executions of queries. It would be hard for us to check in this way, atleast provide some temporary data and some business rules. Only I can IN, >, < (queries logical conditons on inner query)
- Pavan Kumar N
- ORACLE OCP - 9i/10g
https://www.oracleinternals.blogspot.com -
To re-write query using 'ANY' operator
Hi,
How to write the given query using 'ANY ' operator , I dont need to fetch to grade_master table twice in database, just need to fetch within the result set.
SELECT dsg_code,dsg_name,dsg_grade FROM designation_master WHERE dsg_orgn='&&Orgn' and dsg_ctry='&&ctry'
And dsg_loc ='&&loc' And dsg_oru = '&&oru' and dsg_grade in decode('&&radio_group',
1, SELECT grd_code FROM grade_master WHERE grd_osm_code in (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&Orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'),
2, SELECT grd_code FROM grade_master WHERE grd_osm_code > (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code),
3, SELECT grd_code FROM grade_master WHERE grd_osm_code < (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'))
thanks
rincyTubby is correct that data and create statements are required to analyze it correctly.
Still I worked on it and created something using WITH clause
with grd_query
as
(Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade')
,grd_mst_query
as
(SELECT grd_code, grd_osm_code FROM grade_master)
SELECT dsg_code, dsg_name, dsg_grade
FROM designation_master
WHERE dsg_orgn = '&&Orgn'
AND dsg_ctry = '&&ctry'
AND dsg_loc = '&&loc'
AND dsg_oru = '&&oru'
AND dsg_grade in
decode('&&radio_group',1, (SELECT grd_code FROM grd_mst_query WHERE grd_osm_code in (select * from grd_query)),
2, (SELECT grd_code FROM grd_mst_query WHERE grd_osm_code > (select * from grd_query)),
3, (SELECT grd_code FROM grd_mst_query WHERE grd_osm_code < (select * from grd_query)))this should avoid multiple scans on same table.
thanks -
Hello SDN:
We are on BW 3.5 SP16.
We are currently using a replacement path Query(RP) with variables
to populate a variable in another Query(T).
The problem we are having is with performance.
The entry of variables in replacement path Query(RP) is optional (This is necessary there cannot be required values)
When results from Replacement Path Query are small performance is fine. (e.g. 10 seconds)
When results from Replacement path query are large performance suffers. (e.g. 1+ minutes)
Users are free to leave the replacement path variables empty resulting in a large set of data to be replaced. This is the worst performance case.
We would like to discover a way to conditionally execute the replacement path query. That is if users do not enter values for the replacement Query(RP) variables do not execute the replacement path query(RP).
Does anyone know if this is possible within reason and in customer exit space?
We have reviewed the situation from all angles and the requirement for the replacement path FUNCTIONALITY and the freedom for the user to leave variable values blank remains.
I've been searching and reading SDN and SAP notes for about a week and do not find threads which address this situation.
We are also exploring Customer variable exits to mimic replacement path functionality
(different topic subject="How do I...Mimic Replacement Path with Query using Customer Variable Exits?")
Any help will be appreciated
Many thanks
David SchuhMy appologies-I posted this message with the wrong subject. I will repost it with appropriate subject.
dave schuh -
Is there a compatability issue with Firefox and Andriod operating system 2.2.3? I can't get Firefox to work. I have tried uninstalling it and it won't download. in English
Hi Drbobdog, there shouldn't be a compatibility with Android OS 2.2.3. There may be a compatability with the device itself.
Here are the system requirements:
https://wiki.mozilla.org/Mobile/Platforms/Android#System_Requirements
(also seen here as well : http://www.mozilla.org/en-US/mobile/platforms/ )
I hope this helps. -
table a
=========
id (number),name varchar2,dt date
10,'aaa','01-01-2006'
11,'bbb','01-01-2007'
table b
======================
id varchar2,name varchar2,dt varchar2
'10','aaa','01-01-2006'
is it possible to find out which row is not in table b but it is in table a
i have tried out using minus operator but it return error (ora-01790-expression must have same datatype.ora-01790-expression must have same datatypeAnd what is it precisely is it about that error message which is confsuing you?
SQL> select 1 from dual
2 minus
3 select dummy from dual
4 /
select 1 from dual
ERROR at line 1:
ORA-01790: expression must have same datatype as corresponding expression
SQL> select to_char(1) from dual
2 minus
3 select dummy from dual
4 /
T
1
SQL> Cheers, APC -
Performance issues with query input variable selection in ODS
Hi everyone
We've upgraded from BW 3.0B to NW04s BI using SP12.
There is a problem encountered with input variable selection. This happens regardless of using BEx (new or old 3.x) or using RSRT. When using the F4 search help (or "Select from list" in BEx context) to list possible values, this takes forever for large ODS (containing millions of records).
Using ST01 and SM50 to trace the code in the same query, we see a difference here:
<u>NW04s BI SQL command</u>
SELECT
"P0000"."COMP_CODE" AS "0000000032" ,"T0000"."TXTMD" AS "0000000032_TXTMD"
FROM
( "/BI0/PCOMP_CODE" "P0000" ) LEFT OUTER JOIN "/BI0/TCOMP_CODE" "T0000" ON "P0000"."COMP_CODE" = "T0000
"."COMP_CODE"
WHERE
"P0000"."OBJVERS" = 'A' AND "P0000"."COMP_CODE" IN ( SELECT "O"."COMP_CODE" AS "KEY" FROM
"/BI0/APY_PP_C100" "O" )
ORDER BY
"P0000"."COMP_CODE" ASC#
<u>BW 3.0B SQL command:</u>
SELECT ROWNUM < 500 ....
In 3.0B, rownum is limited to 500 and this results in a speedy, though limited query. In the new NW04s BI, this renders the selection screen unusable as ABAP dumps for timing out will occur first due to the large data volume searched using sequential read.
It will not be feasible to create indexes for every single query selection parameter (issues with oerformance when loading, space required etc.). Is there a reason why SAP seems have fallen back on a less effective code for this?
I have tried to change the number of selected rows to <500 in BEx settings but one must reach a responsive screen in order to get to that setting and it is not always possible or saved for the next run.
Anyone with similar experience or can provide help on this?here is a reason why the F4 help on ODS was faster in BW 3.x.
In BW 3.x the ODS did not support the read mode "Only values in
InfoProvider". So If I compare the different SQL statements I propose
to change the F4 mode in the InfoProvider specific properties to
"About master data". This is the fastest F4 mode.
As an alternative you can define indexes on your ODS to speed up F4.
So would need a non-unique index on InfoObject 0COMP_CODE in your ODS
Check below for insights
https://forums.sdn.sap.com/click.jspa?searchID=6224682&messageID=2841493
Hope it Helps
Chetan
@CP.. -
Issue with Query on a virtual infoprovider
Hello,
I am getting the following error message while executing a query on a virtual infoprovider. We have recently gone through upgrade from BI 3.5 to BI 7.0 EHP1 (SP5) and from SEM BCS 4.0 to BCS 6.0.
EVersion not specified or not unique UCR0 006
EError reading the data of InfoProvider ZBCS_CV11 DBMAN 305ZBCS_CV11
EError while reading data; navigation is possible BRAIN 289
I>> Row: 11 Inc: RAISE_READ_ERROR Prog: CL_RSDRV_VPROV_BASE RS_EXCEPTION 301CL_RSDRV_VPROV_BASE
this query has been running fine before the upgrade. In the selection screen there are two fields - version1 and version2, if I am specifying same value in both the fields then the query runs fine and if I am providing different values then the above stated error message appears.
I have tried different settings with properties - Read mode: H,A,X and also different combination from the properties of the virtual infoprovider - with and w/o hierarchies; with and w/o navigation attributes but it did not workout.
the only thing which has changed on this virtual provider is that I had enabled delta caching as this was supposed to be used in a multiprovider.
Has anyone experienced similar issue or have an idea as to what is going wrong here. Please advice.
Regards,
ManishHi Manish,
I have exactly the same issue with a query on a virtual infoprovider after upgrading from BI 3.5 to BI 7.0 EHP1 (SP5) and from SEM BCS 4.0 to BCS 6.0.
Would you be so kind to tell me how you fixed this. (other queries seem to be working)
Kind regards,
Jamie Flaxman -
Writing query using UNION Operator
Question -
(1)
Write an SQL Statement to list the following items: Customer ID, Customer Name, number of invoices, sum of total for invoices. Ensure that all customers are returned in the result set.
Answer for the above is written as below by one person. That seams to be correct. Is there another way of writing this same query.;
select c.CUSTOMER_ID,c.NAME,i.cnt,i.s
from gee_customer c,(select customer_id,count(*) as cnt, sum(TOTAL) as s
from gee_invoice
group by customer_id) i
where c.CUSTOMER_ID = i.customer_id (+)
(2)
My other question is How to write the above answer (or what you sugest) using UNION operator ?
Any ideas please
Message was edited by:
user483578In fact the outer join means you use the union of two result sets - usual join result
and the rows from the outer table for which there is not any row in the inner table.
SQL> select d.deptno, e.ename from emp e, dept d
2 where d.deptno = e.deptno(+)
3 order by 1,2
4 /
DEPTNO ENAME
10 CLARK
10 KING
10 MILLER
20 ADAMS
20 FORD
20 JONES
20 SCOTT
20 SMITH
30 ALLEN
30 BLAKE
30 JAMES
30 MARTIN
30 TURNER
30 WARD
40
15 rows selected.
SQL> select d.deptno,e.ename from emp e, dept d
2 where d.deptno = e.deptno
3 union
4 select deptno, null
5 from dept d where not exists (select null from emp e where e.deptno = d.deptno)
6 order by 1,2
7 /
DEPTNO ENAME
10 CLARK
10 KING
10 MILLER
20 ADAMS
20 FORD
20 JONES
20 SCOTT
20 SMITH
30 ALLEN
30 BLAKE
30 JAMES
30 MARTIN
30 TURNER
30 WARD
40
15 rows selected.In your example something like (NOT tested !)
with i as (select customer_id,count(*) as cnt, sum(TOTAL) as s
from gee_invoice group by customer_id)
select c.CUSTOMER_ID,c.NAME,i.cnt,i.s
from gee_customer c, i
where c.CUSTOMER_ID = i.customer_id
union
select c.CUSTOMER_ID,c.NAME,null,null
from gee_customer c
where not exists (select null from i where c.CUSTOMER_ID = i.customer_id)
Rgds. -
How to pass variable into lov sql query using like operator
hi.
i want to use a lov where i want to pass a variable using like operator.
my query is
select empno,name from table where empno like ':ed%';
my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
how can i do this ?
reagrdskindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
and provide us with that detail
and its better if you start new topic for that error... because that will be new error,,,
-- Aamir Arif
Edited by: Aamiz on Apr 7, 2010 12:27 PM -
hi there,
I have an issue with the display of hours 00:00:00 in the query output in BW.
The system assumes it as 0 or blank and therefore display it under unassigned hour.
I am using the reference of 0TIME for this hourly display.
When I checked the 0TIME i could not find the corresponding SID value for 00:00:00 hours.
Can anybody please advise what needs to be done?
Thanks in advance,
Kind regard,
KateHi Kate,
I am experiencing the same problem as you: an InfoObject, created referencing 0TIME, represented in the BEX Query as "#" when the Value is "00:00:00".
How did you work it out?
The Formula Variable strategy is not applicable in this case because 0TIME is not a key figure !
Bye
Aldo -
Issue with Alerts using BPM : Trigerred for Successful messages also
Hi Everybody,
I am working on configuring Alerts using BPM.
I have followed the below blog by Micheal.
/people/michal.krawczyk2/blog/2005/03/13/alerts-with-variables-from-the-messages-payload-xi--updated
In BPM after the receive step I have used container and control steps to capture the Idoc Number as mentioned in the blog.
I am facing an issue with it now as an Alert message is send to my Inbox even when the message is succesfully processed by the adapter.
This is a strange behaviour when we talk about Alerts.
Can somebody help me out in this?
Thanks & Regards,
ZabiullaHi Zabiulla,
Michal explained just the basic, the logic of your process is to build by yourself. Usually an alert will be raised inside of an exception branch. You can define exceptions for critical operations, f.e. send steps or transformations, the exception will be catched by jumping to the exception branch, where you can store a suitable reaction - f.e. an alert.
Regards,
Udo -
Performance Issue in Query using = and =
Hi,
I have a performance issue in using condition like:
SELECT * FROM A WHERE ITEM_NO>='M-1130' AND ITEM_NO<='M-9999'.
Item_No is a varchar2 field and the field contains Numberical as well as string values.
Can anyone help to solve the issue.
Thanks and RegardsHow can you say it is a performance issue with the condition? Do you have execution plan? If yes, post it between [pre] and [/pre] tags. Like this.
[pre]SQL> explain plan for
2 select sysdate
3 from dual
4 /
Explained.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 1546270724
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
8 rows selected.
SQL>
[/pre] -
Issue with printing newly added operations in Production Order through CO02
Hi,
Currently I have one issue with printing production order changes through CO02. If I go for print, all the operations are captured in printout. But after the print, if I add any new operations to this production order, and then go for print, its not capturing the newly added operations. Also, there is information popup coming "Copies will be printed for order. Original list already printed". This message effectively means, even after changes, when I go for print functionality, its just going for printing copies of original printed list.
Can anyone help me out to get the newly added operations reflected in the print through CO02 ?
Regards,
ShivaHi,
1) Go to Tcode "OPK8"
2)Select LG02 "Op Control Ticket"
3) Double click on :List Control for Transactions" in the left hand menu tree
4) In front of ur desired t code "co02" make the changes ( Number of prints- u can increase) 6th column.
Try this.
Maybe you are looking for
-
MIRO FI DOCUMENT NOT GENERATED
< MODERATOR: Message locked. Please read the [Rules of Engagement|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement] before posting next time. Don't use ALL CAPS in your title.> Hi pls help me on this MIRO invoice posting ha
-
Why can't I restore my iPhone 5?
I got my iPhone 5 about a month ago and this morning I left it on my bed to shower, my niece loves using it to play games so I gave her the password, however she somehow ended up changing the password without knowing exactly what she was doing; just
-
I have installed the updated version of Firefox but it has automatically disabled my Kaspersky anti virus web browsing extension. I have now uninstalled Firefox and would like the earlier version back please.
-
ICal (Version 3.0.8) not updating
Hi I am running iCal Version 3.0.8 on my MacBook OSX 10.5.8. My Calendar syncs between my iPhone and MobileMe, but the calebndar on my Mac shows no entries at all. I have set it up to sync with MobileMe via system prefs and I am signed in. Calendar i
-
To All IPAD users, I think Apple has shot itself in the foot as the old saying goes. Magazine developers are not developing iOS6+ firmware for the 1st Generation iPad. This is a serious ommission on Apples behalf. Remember! If it can happen to 1st Ge