Inner join working too long
First I am using Oracle 8i
The problem is next. I have two subqueries. Lets call them S1 and S2. Both have the field ID (which is of type varchar2(11) just from different tables T1 and T2).
S1 have about 8000 rows and S2 - 36000 (no problems here). We want to join these tables into one. It is simple? It should be. I wrote next query:
SELECT count(*)
FROM S1, S2
WHERE S1.ID = S2.ID
AND S1.date BETWEEN S2.from_date AND S.to_date
It is working. But it works very long. More than 30 min. I wrote another query with outer join.
SELECT count(*)
FROM S1, S2
WHERE S1.ID = S2.ID (+)
AND S1.date BETWEEN S2.from_date AND S.to_date
This one works less than one min. If i correctly understand - both queries should work for about the same amount of time. Could someone explain me what i am missing.
OK, here is my query. A.asm_ak and B.pacientas are fields of the same type and store the same data. First subquery give the list of the people and their visit dates from asm_nepatv and gydymo_lapai. Another subquery gives the list of the people and additional information from asmenys and other tables.
I checked these two tables asmenys and asm_nepatv. These fields do not have keys or indexes.
select count(*)
from
(select asm_ak, gal_atvykimo_data adata
from gydymo_lapai, asm_nepatv
where gal_asmn_id = asm_nepatv.asm_id
and asm_nepatv.asm_ak IS NOT NULL
and gal_pabaigos_data >= to_date(?,'YYYY.MM.DD')
and gal_pabaigos_data < to_date(?,'YYYY.MM.DD')
) A,
select gist_pav, pas_profilis SPEC, asmenys.asm_ak pacientas, reg_data_nuo pnuo, reg_data_iki piki, asm.asm_pavarde||' '||asm.asm_vardas gdt, gdis_data_nuo gydnuo, gdis_data_iki gydiki
from asmenys, reg_gi, instaliacija, gyd_isidarbinimai, gydytojai, asmenys asm, gydymo_istaigos, darbo_vietos, paslaugos
where asmenys.asm_id = reg_gi.reg_asm_id
and reg_gi.reg_gist_id = instaliacija.gist_id
and reg_gi.reg_dv_id = gyd_isidarbinimai.gdis_dv_id
and dv_id = reg_dv_id
and dv_pas_id = pas_id
and gyd_isidarbinimai.gdis_gdt_id = gydytojai.gdt_id
and instaliacija.gist_id = gydymo_istaigos.gist_id
and gydytojai.gdt_asm_id = asm.asm_id
and reg_gi.reg_data_nuo <= to_date(?,'YYYY.MM.DD')
and reg_gi.reg_data_iki >= to_date(?,'YYYY.MM.DD')
and (to_date(?,'YYYY.MM.DD') - asmenys.asm_gim_data)/365.25 >= 0
and (to_date(?,'YYYY.MM.DD') - asmenys.asm_gim_data)/365.25 < 120
) B
where A.asm_ak = B.pacientas (+)
and A.adata between pnuo and pikiEdited by: user512088 on 2009.3.31 05.32
Edited by: user512088 on 2009.3.31 05.33
Edited by: user512088 on 2009.3.31 05.35
Edited by: user512088 on 2009.3.31 05.40
Similar Messages
-
Does INNER JOIN work with Oracle 8i ? (ORA-00933)
hi,
I try to execute the sql:
SELECT
A0.FULL_NAME,A0.MANAGER_ID,A0.DEPT_NO,A0.TOP_DEPT
FROM
HR_ORG A0
INNER JOIN
HR_EMP A1
ON
A0.MANAGER_ID=A1.EMP_NO
WHERE
A1.NAME = 'michael'
but I caught an exception:
java.sql.SQLException: ORA-00933: SQL...(message in
chinese)
Does INNER JOIN work with Oracle 8i ?
thanks.INNER JOIN syntax is introduced in 9i, it does not exists in 8i. You can rewrite your statement:
SELECT
A0.FULL_NAME,A0.MANAGER_ID,A0.DEPT_NO,A0.TOP_DEPT
FROM
HR_ORG A0
, HR_EMP A1
WHERE
A0.MANAGER_ID=A1.EMP_NO
AND
A1.NAME = 'michael' -
Inner join searches too many entries
Hi experts,
In a user exit following code is used:
DATA : h_rsnum LIKE afko-rsnum,
h_charg LIKE resb-charg,
h_matnr LIKE resb-matnr,
SELECT SINGLE rsnum INTO h_rsnum
FROM afko
WHERE aufnr = x_bncom-aufnr.
IF sy-subrc = 0 .
SELECT resbcharg resbmatnr
INTO (h_charg, h_matnr)
FROM mara INNER JOIN resb
ON maramatnr = resbmatnr
WHERE resb~rsnum = h_rsnum
AND resb~charg NE space
AND maramtart = 'HALB' OR maramtart = 'FERT'.
ENDSELECT.
Goal of the source code is to detemine the reservation number of a process order. From table RESB with key h_rsnum, the material nb and the batch nb of the single material with material type HALB or FERT needs to be selected.
During debugging I found out that this code searches into a very long list of materials before ending up with the correct h_charg and h_matnr.
If the condition resb~rsnum = h_rsnum would be taken into account when creating the inner join, the list would only contain 20 materials maximum.
Can this behaviour be changed and how to do it?
Rgds,
Suzyif this is inside a user exit 1st of all why are you using a select endselect and i dont see you take that in to a table which means your only looking for one record.
about you tell that before the inner join taking the where condition into consideration. I dont think it will be possible sine normally after making the join it should go for the where condition anyway ill try to check on it and see.
sometimes Siegfried might know an answer dont know if he saw this.
Nafran
Edited by: Nafran Shiraz on Jun 4, 2009 12:36 PM -
Inner join. error. too long. unique. unique
hi,
I am a beginer to ABAP and trying to do an inner join using 3 tables that are given by SAP
scustom, spfli, and sbook. I want to join these 3 tables and get
the customer booking info and wants the result of
customer_no , cust_name, Booking_ID, City_From, City_To, etc.
my query i s below.
select cid cname bbookid bconnid bfldate fcityfrom f~cityto
into table it_scust
from ((scustom as c inner join sbook as b
on cid = bcustomid)
inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).
when i execute the program i am getting the error that the 'query is too long. unique. unique. unique.'.
If I am joing only two tables it is working fine. Is there something wrong with my query? Any ideas on this? Please help.
Thanks in advance.Hi neeraja,
what ever the code you have written is fine but it is unique/ too long means the code you have written is not ending perfectly which is not identified by syntax error. your code is
select cid cname bbookid bconnid bfldate fcityfrom f~cityto
into table it_scust
from ((scustom as c inner join sbook as b
on cid = bcustomid)
inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).
iam sending the same code but with little modification just try this u will get the output.
select cid cname bbookid bconnid bfldate fcityfrom f~cityto
into table it_scust
from (scustom as c inner join sbook as b
on cid = bcustomid)
inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid.
find the difference what i made.
pls reward points if it is helpful. -
Many times my computer takes too long to connect to new website. I have wireless internet (time capsule) and I am running a pretty powerful real time financial work program at same time, what is the best solution? Upgrading speed from cable network? is it a hard drive issue? do I only need to "clean out" the computer? Or all of the above...not to computer saavy. It is a Macbook Pro osx 10.6.8 (late 2010).
Almost certainly none of the above! Try each of the following in this order:
Select 'Reset Safari' from the Safari menu.
Close down Safari; move <home>/Library/Caches/com.apple.Safari/Cache.db to the trash; restart Safari.
Change the DNS servers in your network settings to use the OpenDNS servers: 208.67.222.222 and 208.67.220.220
Turn off DNS pre-fetching by entering the following command in Terminal and restarting Safari:
defaults write com.apple.safari WebKitDNSPrefetchingEnabled -boolean false -
Link for BUT000 table and ADRC in CRM and inner join is not working in PCUI
Hi Gurus,
Please tell me the link btween BUT000 and ADRC table. and i wrote one inner join between BUT000 and BUT0id table but it not working. I m in CRM 4.0 version working with PCUI.
select but000partner but000name_org1 but000name_org2 but000bus_sort1 but0id~parnter1
but0ididnumber from but000 inner join but0id on but0idpartner = but000~parnter
into corresponding fields of table it_result where partner in s_partner.
It is giving error as partner unknown from but000 table. I delcared everything and tried with alias names also.
please clarify me.
regards,
Ramakrishna.Hi Frederic,
thanks a lot. But is inner join between BUT000 and BUT0ID will work. for me it is not working. plesae see this code.
tables : but000,
but0id,
crmm_but_custno,
adrc.
types : begin of typ_but000,
partner type bu_partner,
name_org1 type BU_NAMEOR1,
name_org2 type BU_NAMEOR2,
bu_sort1 type BU_SORT1,
idnumber type BU_ID_NUMBER,
partner1 type bu_partner,
end of typ_but000.
data: lt_but000 type table of typ_but000,
ls_but000 like line of lt_but000.
*select-options : s_partnr for but000-partner.
start-of-selection.
select but000partner but000name_org1 but000name_org2 but000bu_sort1 but0id~parnter1
but0id~idnumber into corresponding fields of table lt_but000 from but000
inner join but0id on but0idpartner = but000parnter. " where partner in s_partner.
it is giving error as but000-partner is not know or but0id-partner not known.
So, i think if it not works then i should write two select stmts.
please clarify me.
i gave u rating.
thanks
ramakrishna. -
I have the converter to change pdf to word. Works sometime, other time says conversion is taking too long. Can I get what it has translated so I can use the parts?
I would ask in the ExportPDF forum, Adobe ExportPDF (read only) (assuming that's the service to which you have subscribed). This is the Reader one.
-
Inner join query not working properly
Hi everyone,
It does not gives any error, but it is not fetching any values...but when i dont include fourth table CSKT AND THE FIELD LTEXT it is fetching the values.
SELECT SINGLE
T1~PERNR
T1~BEGDA
T1~ENAME
T1~PLANS
T1~KOSTL
T2~STRAS
T2~PSTLZ
T2~ORT01
T3~PLSTX
T4~LTEXT
INTO FS_TAB
FROM PA0001 AS T1
INNER JOIN PA0006 AS T2 ON T1PERNR eq T2PERNR
INNER JOIN T528T AS T3 ON T1PLANS EQ T3PLANS
INNER JOIN CSKT AS T4 ON T1KOSTL EQ T4KOSTL
WHERE T1~PERNR eq p_pernr.Change like this
SELECT SINGLE
T1~PERNR
T1~BEGDA
T1~ENAME
T1~PLANS
T1~KOSTL
T2~STRAS
T2~PSTLZ
T2~ORT01
T3~PLSTX
T4~LTEXT
INTO FS_TAB
FROM PA0001 AS T1
INNER JOIN PA0006 AS T2 ON T1~PERNR eq T2~PERNR
INNER JOIN T528T AS T3 ON T1~PLANS EQ T3~PLANS
LEFT OUTER JOIN CSKT AS T4 ON T1~KOSTL EQ T4~KOSTL
WHERE T1~PERNR eq p_pernr.
OR
SELECT SINGLE
T1~PERNR
T1~BEGDA
T1~ENAME
T1~PLANS
T1~KOSTL
T2~STRAS
T2~PSTLZ
T2~ORT01
T3~PLSTX
T4~LTEXT
INTO FS_TAB
FROM PA0001 AS T1
LEFT OUTER JOIN PA0006 AS T2 ON T1~PERNR eq T2~PERNR
LEFT OUTER JOIN T528T AS T3 ON T1~PLANS EQ T3~PLANS
LEFT OUTER JOIN CSKT AS T4 ON T1~KOSTL EQ T4~KOSTL
WHERE T1~PERNR eq p_pernr.
as long as the table is not used in where condition, u can use left outter join. -
Work area is not too long enough
hi,
i am trying to insert data into a custom table and i use the statement
insert ztable from workarea.
and i get the syntax error "work area is not too long enough".
i have a mandt field as the first field in my custom table. workarea is defined to hold the rest of the vaules.
whats wrong ?
thksI have tried as you said. My logic is following:
FORM update_table .
DATA wa_event1 TYPE zps_event.
CLEAR wa_event1.
wa_event1-pspid = lv_proj.
wa_event1-category = p_cate.
wa_event1-long_text = p_event.
wa_event1-erdate = p_date.
INSERT zps_event FROM wa_event1.
IF sy-subrc IS INITIAL.
WRITE: 'Successful'.
ENDIF.
ENDFORM. " UPDATE_TABLE
In p_event I gave following this input:
Do the implementation for the same class to handle the event i.e. if we select a radio button, then the already selected radio button should be deselect and new radio button should be selected. Code as follows.
But when I checked in ZTABLE, the field contains only:
Do the implementation for the same class to handle the event i.e. if we select a radio button, then the already selected radio b
Any thing wrong in my code?? -
My string URL is too long and my servlet don't work.
I need to call servlet from my web page but it does not work because My string URL is too long (appear message in my web "server not found"), exists a way to solve this?
It's good that you have a solution. But your solution suggests that your original problem was not that the URL was too long, since you are still using GET. Probably it was something else. But at least you have a solution.
-
I recently updated to ios5.0.1 and was syncing my itouch.I noticed that it was taking too long and my itouch turned off. now, i can't turn it on.went online and tried everything from the troubleshooting assistant but nothing works. HELP PLEASE!
Have yu tried everthing here:
iOS: Not responding or does not turn on
Next see if placing the iPod in DFU mode will allow iTunes to see the iPod so you can restore the iPod.
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
Last, make an appointment a the Genius Bar of an Apple stroe. -
how can i go to DFU mode if my sleep/wake button doesn't work? my phones been stuck on the logo for too long.
You can't. Either get your phone fixed at a third-party repair shop, or go to an Apple store & they will replace your phone for US $199.
-
firefox is taking way too long to load pages. I have a very fast internet connection but firefox takes forever to load websites. At first it worked fine and very fast but now very slow??
Hi there!
do you test other browsers?
i suggest to make a clean install of newer version of Firefox like v8.0. -
Multiple inner join ..how they work ?
Here is an example of INNER JOIN.
SELECT whatever
FROM tablea AS a
INNER
JOIN tableb AS b
ON b.b = a.a
INNER
JOIN tablec AS c
ON c.c = b.b1
INNER
JOIN tabled AS d
ON d.d = c.c1As you see there are 3 inner join in a single query ...I'm uncomfortable with this ....because I dont know what is the order of execution of multiple inner joins .
which inner join will be executed first and which is next and which is last ?Hi,
user575089 wrote:
but you know my concern is .... is not the result of inner join is fed to the next inner join ? ( because there is multiple inner join )Sorry, I don't know what your concern is. Try to explain it, prefereably with a concrete example. Post a specific query, using the dept, emp and salgrade tables in the scott schema (or 3 tables for which you post CREATE TABLE and INSERT statements), and a specific question about that query. If you really need 4 tables to show what your problem is, you can use the hr schama instead of scott.Is it possible to test using MySQL ? What happens when you try it?
I know its an oracle forum You're right; this is an Oracle forum.
....that should not be a problem I guess... ..coz SQL is a universal language ...The English language spoken in Britain is different from the English language spoken in the United States. The differences are minor compared to, say, the differences between either and Hindi, but there are differences.
The SQL langauge used in Oracle is different from the SQL language used in MySQL, even more that the English language used in Britain is different from the English language used in the United States.
I'm guessing that how MySQL and Oracle perform inner joins is pretty similar, as far as it matters for your question, but that's just a guess. I don't know a lot about MySQL, and I don't know what your question is. -
How to return all rows with duplicate values? Inner join not working!
I have a 3 column table:
location (pk), name, size
I am attempting to select pairs of entries that have the same
name and size but different values for location (it is the
primary key.) My inner join does not seem to return what I need:
select a.location, a.name, a.size, b.location, b.name, b.size
from mytable a, mytable b where a.name = b.name and a.size =
b.size and a.location <> b.location;One solution is like this:
SELECT dname, loc, deptno
FROM dept
WHERE (dname, loc) IN
(SELECT dname, loc
FROM dept
GROUP BY dname, loc
HAVING COUNT (*) > 1
ORDER BY dname, loc, deptno
Regards
Zlatko Sirotic
Maybe you are looking for
-
Message sent from XI but queue in waiting
Hi Guys, I am facing a strange problem in XI. First of all cleared all the inbound and outbound queues in XI. Then I ran an async service from XI. The flow is as follows. XI --> SCM system(PROXY) (PROXY)SCM>XI>HTTP So as per the flow the response cam
-
How does one preserve the original creation date on photos exported from iPhoto? My wife and I use different cameras and want to integrate our pictures. The only way to do so is by creation date. But when I export my photos from iPhoto the creatio
-
Iphoto 11 not saving my edits. HELP????
What is going on? Can't save my edited photos? Anybody know about this? Thanks.
-
Hi All, I have a formula like this NODIV(100((A-B)/A)) But this is showing that syntax errors are there. Please let me know if any error is and is it correct? Thanks in advance Sravani
-
Hey- So I might be aquiring a first gen PowerMac G5 for a pretty cheap deal. First Gen products usually have at least some small issue or bug no matter what the product is. I was wondering what what they were for the first gen G5's. Thanks