Using MANDT field in Inner joins
Experts,
I need your suggestions on using MANDT field in JOINS. Example
Select afield1 afield2 b~field1 from table1 as a
inner join table 2 b on amandt = bmandt
afield1 = bfield1
where......
Will it be a performance issue if I use the join without MANDT field?
Anand
probably stated in the note:
mandt in the WHERE condition is automatically added, but not in ON-condition.
Some databases had problems to figure out, that the mandit is always the same, i.e. did not use an index on second table. So adding mandt in ON condition can have impacts. In newer database releases this is no problem anymore. But anyway, the additional line in the ON-condition is no big deal.
Siegfried
Similar Messages
-
Is there any way to use MAX on an INNER JOIN???
I am getting the MAX Date row on a previous INNER JOIN and then I want to use that result row to get an Account Balance. I know it's hard to explain without the SQL but I'll try...
So I want the MAX(BILLHDR.dt_bill)'s Account Balance...
SELECT PYMTADJ.ky_payment_adjustment,
PYMTADJ.ky_enroll,
PYMTADJ.dt_payment_adjustment,
PYMTADJ.at_payment_adjustment,
MAX(BILLHDR.dt_bill) Last_Bill_Date,
MAX(BILLHDR.dt_reading_from) "Last Bill Period From Date",
MAX(BILLHDR.dt_reading_to) "Last Bill Period To Date",
BILLHDR2.at_bill_account_balance
FROM PVIEW.PAYMENT_ADJUSTMENT PYMTADJ
LEFT OUTER JOIN PVIEW.BILL_HDR BILLHDR
ON PYMTADJ.ky_enroll = BILLHDR.ky_enroll
AND BILLHDR.dt_bill <= '15-Jun-2009'
INNER JOIN PVIEW.BILL_HDR BILLHDR2
ON BILLHDR.ky_enroll = BILLHDR2.ky_enroll
AND MAX(BILLHDR.dt_bill) = BILLHDR2.dt_bill
Any help would be GREATLY appreciated.
Thanks.
PSULionRP[email protected] wrote:
But now the next riddle is this. I have another table I have to query against using those MAX Dates. Is there any way to use those MAX Dates as my Join criteria for another table???Sure, it is called in-line view:
SELECT whatever-you-need
FROM (
SELECT pymtadj.ky_payment_adjustment, pymtadj.ky_enroll,
pymtadj.dt_payment_adjustment, pymtadj.at_payment_adjustment,
MAX (billhdr.dt_bill) last_bill_date,
MAX (billhdr.dt_reading_from) "Last Bill Period From Date",
MAX (billhdr.dt_reading_to) "Last Bill Period To Date",
MAX (billhdr2.at_bill_account_balance)KEEP (DENSE_RANK FIRST ORDER BY billhdr.dt_bill DESC) some_alis
FROM pview.payment_adjustment pymtadj LEFT OUTER JOIN pview.bill_hdr billhdr
ON pymtadj.ky_enroll = billhdr.ky_enroll
AND billhdr.dt_bill <= TO_DATE ('15-Jun-2009', 'DD-Mon-YYYY')
LEFT OUTER JOIN pview.bill_hdr billhdr2
ON billhdr.ky_enroll = billhdr2.ky_enroll
GROUP BY pymtadj.ky_payment_adjustment,
pymtadj.ky_enroll,
pymtadj.dt_payment_adjustment,
pymtadj.at_payment_adjustment
) inline_view JOIN another_table ON(inline_view."Last Bill Period From Date" = another_table.some_column1)SY. -
About a question using Update ... inner join ?
select *
FROM a
INNER JOIN b ON a.ProductID=b.ProductID
WHERE a.HeadID='000246'
this statement is ok ;
But the following statement does not work ! Why ?
UPDATE a SET
a.Quantity=a.PurchaseQuantity/b.ConversionGene
FROM a
INNER JOIN b ON a.ProductID=b.ProductID
WHERE a.HeadID='000246'"Because Oracle syntactically does not support that type of construct..." Is a correct statement, but not because "It expects only one table in UPDATE statement". The synatax for an updateable join in Oracle requires a "proper" in-line view to be updated.
As long as the table joined (in my example t1) has a declared unique constraint on the columns used to join by (in my example id), you can do it like:
SQL> SELECT * FROM t;
ID DESCR
1 One
2 Two
3 Three
SQL> SELECT * FROM t1;
ID DESCR2
1 Un
2 Deux
SQL> UPDATE (SELECT t.descr, t1.descr2
2 FROM t
3 JOIN t1 ON t.id = t1.id)
4 SET descr = descr2;
2 rows updated.
SQL> SELECT * FROM t;
ID DESCR
1 Un
2 Deux
3 ThreeTTFN
John -
Implications of not using mandt field in SAP table.
Hi Everyone,
Can anybody please let me know the diadvantage and the impact of not using the mandt field at the key field in the db table. And what will be the impact if the customer upgrades the system and if the tables doesnt have this field. Any help will of great use to me.
Thanks,
Prashant.SAP has the concept of client dependent and client-independent data. This is controlled by the mandt field as the first field in a table which makes it a client dependent table. as there can be multiple clients supported in a single sap system, it is better to have this differentiation so that the data in one client can be clearly distinguished from that of another.
however, this does not hold for certain types of data such as the customizing data which is to be maintained singly across all clients. Thus, such tables which need to have a single definition of data across all clients available in the system should be made client independent, that is , without the mandt field in the table.
once you use client-dependent tables, different clients in the system can even be used as different logical systems, and this certainly helps if data is segregated in multiple client scenario.. -
Alias for field in inner join query
In my Oracle 9i Schema, I have two tables:TableOne
pocOne pocTwo
2 3
2 4
1 2
TableTwo
TableTwoId Name
1 Jones
2 Smith
3 Edwards
4 CamdenMy SQL that works to fetch all records with Smith works great:select Name from TableTwo
Inner Join TableOne
on TableTwo.TableTwoId in (TableOne.pocOne, TableOne.pocTwo)
where Name = 'Smith' Now I need to create an alias for the Name field. Here is my attempt:select myAliasName from TableTwo
Inner Join TableOne
on TableTwo.TableTwoId in (TableOne.pocOne, TableOne.pocTwo), (select Name as myAliasName from TableTwo)
where myAliasName = 'Smith' This attempt pulls up all the records instead of just Smith records. Please advise how I can create an alias for the Name field in my above query?Are you just looking for
select Name AS AliasName
from TableTwo Inner Join TableOne
on TableTwo.TableTwoId in (TableOne.pocOne, TableOne.pocTwo)
where Name = 'Smith' Justin -
Regarding : What is used in place of inner join
hi,
i want to know that we use to have inner joins in our reports and i want to know is there anything which can be used in place of it?Hi,
In place of inner join you can use FOR ALL ENTRIES.
reward point if useful.
Regards
Kumar M -
Help: Modifying inner join
Hello Folks,
I have an Access Query and am rewriting the whole query in Oracle to run a report.The thing is Am a beginner in oracle and am scratching my head on how to modify this inner join. please help me in rewriting this inner join in oracle. thanks a million
((Debtor INNER JOIN MAX_TRANS_DATE AS MAX_TRANS_DATE_1 ON Debtor .
EVENT_ID = MAX_TRANS_DATE_1.EVENT_ID) INNER JOIN
TMP$ALL_RECOVERY_TYPE
ON(Debtor . EVENT_CASE_ID = TMP$ALL_RECOVERY_TYPE . EVENT_CASE_ID) AND
(Debtor . EVENT_ID = TMP$ALL_RECOVERY_TYPE . EVENT_ID))
INNER JOIN CUBS TRANSACTIONS
ON (Debtor . EVENT_ID = CUBS TRANSACTIONS . EVENT_ID)
AND (Debtor . EVENT_CASE_ID = CUBS TRANSACTIONS . EVENT_CASE_ID)Thanks for getting back. But still am unable to get the correct data. I will try to break it down.
Microsoft Access Table MAX_TRANS_DATE menitoned above in the inner join was originally coming from table called TRANSACTIONS i.e.( MAX_TRANS_DATE = SELECT [Transactions].[EVENT_ID], Max([Transactions].[TRANSDATE]) AS MaxOfTRANSDATE
FROM Debtor INNER JOIN Transactions ON [Debtor].[EVENT_ID]=[Transactions].[EVENT_ID]
GROUP BY [Transactions].[EVENT_ID];
Here the problem is am recreating the access database query in oracle database and we dont have MAX_TRANS_DATE in the Oracle database but we do have TRANSACTIONS table.
So i just used TRANSACTIONS in the inner join instead of MAX_TRANS_DATE.
But the result is wrong.The Field Transdate from TRANSACTIONS is pulling dates as 10/5/2006 instead of 02/01/2010. I suspect something is wrong with the joins.Please help me. I can provide the old access query and the new oracle query that i have created.
Thanks
Edited by: user11961230 on Mar 5, 2010 11:49 AM -
Bind variables in inner join queries
Hi all,
can we use bind variables in inner join queries?
eg:
INNER JOIN PRTY_LOC_CODE_T plc ON (ppt.PRTY_REC_ID = plc.PRTY_REC_ID and plc.HIST_CTRL_IND = *0*_ and plc.DEL_IND = *'N'*_)
regards
sunilDear,
can we use bind variables in inner join queries?Where are you using this join? if in a stored procedure or stored function than you don't have to care about your variables. It will be automatically considered as a bind variable
within your static SQL (i.e in your stored procedure)
Hope this helps
Mohamed Houri -
Problem when doing inner join for three tables....
DATA: V3 TYPE VBAP-MAKTL.
SELECT single vbap~matkl into V3
from VBAP
inner join VBFA
inner join LIPS
on LIPSPOSNR = VBFAPOSNN
and vbapvbeln = vbfavbelv
and vbapposnr = vbfaposnv
where LIPSVBELN = VBFAVBELN = '0080000834'
and vbfa~vbtyp_n = 'J'
and LIPS~J_3ASIZE = '0884'.
Error: Wrong expression "INNER" in from clause...Hello Tushar,
Why you are using the 3 table inner join. If the volume of data is big then this statement will give to time out. Use "for all entries" statement to select the data from the table.
Like
select field1 field2 from LIPS into i_lips
where LIPS~J_3ASIZE = '0884'.
select f3 f4 from vbfa into i_vbfa for all entries in i_lips where field1 = i_lips-field1 and so on
and
use same to select data from VBAP.
Hope this will help -
Can I di Inner Join on 2 tables by using only 1 key field?
Hello,
I hv 2 Std. SAP tables, KNVV, KNKK.
- KNVV - does hv 2 key fields (KUNNR and some other, say X)
- KNKK - does hv 2 key fields (KUNNR and some other,say Y)
I want to build a inner join on these 2 tables.
So, Can I do a INNER JOIN on these 2 tables by using ONLY one key field (its KUNNR)? bcoz, there is ONLY common field!!
thank youHi,
The correctness depends on your bussiness requirement. If the common key field is not a primary key, you may end up fetching duplicate entries which you may have to delete after the select query. You dont have to take of any extra precautions in a inner join select query compared to a ordinary select query. Just make sure you use most of the primary key fields of both the tables in the where clause of the select query for better performance
Vikranth -
Issue when suming the field in Select query using inner join
Hi All,
SELECT A~OI_SHNUM
A~FORWAGENT
A~ROUTE
A~SHTYP
A~DTSHP_EACT
A~/BIC/GTCLICENS
A~/BIC/GTCADD04
A~COMP_CODE
SUM( C~GRS_WGT_DL )
C~UNIT_OF_WT
INTO TABLE I_LAYONE
FROM ( ( /BIC/ANTCD000200 AS A
INNER JOIN /BIC/AGSSD000700 AS B ON BOI_SHNUM = AOI_SHNUM )
INNER JOIN /BIC/AGSSD000600 AS C ON CDELIV_NUMB = BDELIV_NUMB ).
I need to sum the field C~GRS_WGT_DL
While compiling it show the error given below
The field "C~UNIT_OF_WT" from the SELECT list is is missing in the
GROUP BY clause. is missing in the GROUP BY clause. is missing in the
GROUP BY clause. is missing in the GROUP BY clause. is missing in the
GROUP BY clause. is "C~UNIT_OF_W
with regards,
ThambeHi,
Try the following SQL statement. Hope it helps you.
SELECT A~OI_SHNUM
A~FORWAGENT
A~ROUTE
A~SHTYP
A~DTSHP_EACT
A~/BIC/GTCLICENS
A~/BIC/GTCADD04
A~COMP_CODE
SUM( C~GRS_WGT_DL )
C~UNIT_OF_WT
INTO TABLE I_LAYONE
FROM ( ( /BIC/ANTCD000200 AS A
INNER JOIN /BIC/AGSSD000700 AS B ON BOI_SHNUM = AOI_SHNUM )
INNER JOIN /BIC/AGSSD000600 AS C ON CDELIV_NUMB = BDELIV_NUMB )
GROUP BY
A~OI_SHNUM
A~FORWAGENT
A~ROUTE
A~SHTYP
A~DTSHP_EACT
A~/BIC/GTCLICENS
A~/BIC/GTCADD04
A~COMP_CODE.
Murthy. -
Relationship between tables while using inner joins.
Hi,
I had a few clarifications on "inner joins", and as i was going through the forum, i came across two points,
1. In one of the threads it said " inner joins is applicable for tables that have a parent child relationship.
2. In another thread it said " inner join is established from master table (the table on the left) to the transcation table (the table on the right)".
I have two clarifications based on the above points.
1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
2. Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>.
Edited by: Narayananchandran on Dec 27, 2010 12:31 PMhave two clarifications based on the above points.
1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
2. Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>
1) NO
2) NO -
How to use BKPF and BSEG without using inner join
Hi,
can anybody plz tell me the logic about how to complete the report without inner joining bkpf and bseg.Is this report can be really be made by using only bseg,bkpf ?
*selection-criteria .
BKPF-USNAM
BKPF-CPUDT
BKPF-BUDAT
BKPF-GJAHR
BKPF-BUKRS
BKPF-BELNR
BSEG-SAKNR
BSEG-LIFNR
BSEG-KUNNR
BSEG-ZUONR
BSEG-SGTXT
Output fields required.
BKPF-BUKRS
BKPF-BELNR
BKPF-GJAHR
BKPF-MONAT
BKPF-BLART
BKPF-CPUDT
BKPF-BLDAT
BKPF-BUDAT
BKPF-USNAM
BKPF-XBLNR
BKPF-STBLG
BKPF-BKTXT
BKPF-WAERS
BKPF-KURSF
BSEG-BUZEI
BSEG-BSCHL
BSEG-KOART
BSEG-UMSKZ
BSEG-SHKZG
BSEG-MWSKZ
BSEG-PSWBT
BSEG-PSWSL
BSEG-DMBTR
BSEG-SAKNR
BSEG-HKONT
BSEG-KOSTL
BSEG-KUNNR
BSEG-VBELN
BSEG-LIFNR
BSEG-ANLN1
BSEG-ANLN2
BSEG-AUFNR
BSEG-MATNR
BSEG-MENGE
BSEG-MEINS
BSEG-ZUONR
BSEG-SGTXT
Thanks,
Rahman
Moderator Message: Please search before posting your question. Thread locked.
Edited by: Suhas Saha on Jan 31, 2012 3:07 PMQuick question - what's preventing your from using built-in functions?
I suggest mapping your Time Dim to a standard Time Dim and work with it - you'll save a lot more time. You'd even need this table if you wanted to work around Todate/AGO.
It is possible to model this functionality w/o functions, but it'll be time consuming task, similar to using Time Series Wizard in Siebel Analytics. You'll need to build aliases and views along with some complex joins (such as TIME.KEY=TIME.KEY-365), introduce a bunch of variables to control. Also, you might not get much flexibility in terms of years. For each year, you'd need an alias table. (TIME_DIM_PY). -
Drag-n-n-drop query joins uses WHERE, not INNER JOIN syntax
When I highlight a few tables and drag them onto the sql worksheet, it will build a select statement for me and join the tables by their foreign keys.
That's a nice feature, thanks!
Three questions. Is it possible to:
1. get it to use the INNER JOIN and LEFT OUTER JOIN syntax instead of joining the tables in the WHERE clause?
2. control the table aliases so that it will automatically use the "standard alias" for the table instead of A, B, C, etc.?
3. get it to not put the schema name into the query?
Thanks!
Edited by: David Wendelken on Nov 22, 2008 1:48 PM. Grammar mistake.Hi Gopi,
Your code is Good.
But try to avoid Inner join with more number of Tables ...because this is a performance issue..
try to use..
select (primary key fields mainly,other fields) from LIKP into itab where bolnr in p_bolnr(paramater).
next try to use for all entries option..
select (primary key fields mainly,other fields) from VBFA for all entries in itab where (give the condition)....
simillarly do for the other select ....ok this will try to reduce the performance issue....
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo -
Hi,
I need a suggestion for improvement of my inner JOIN statement.
internal table itab is of below type
type: begin of ty_itab
field a
field b
field c
field d
end of ty_itab
I have to join two database table TABLE1 and TABLE2. Fields a and d are from TABLE2 and fields b and c are from TABLE 1.
But in the internal table I must have the fields in the order fielda,b,c,d.
Which of the below two options will be better for performance ? And why ?
option 1:
SELECT tab2~a
tab1~b
tab1~c
tab2~d into corresponding fields of itab from TABLE1 as tab1 and TABLE2 as tab2 on..........
option2:
SELECT tab1~b
tab1~c
tab2~a
tab2~d into corresponding fields of itab from TABLE1 as tab1 and TABLE2 as tab2 on..........
Thanks in advance...
Best Regards
Ananya Mukherjee
Moderator message - Cross post locked
Edited by: Rob Burbank on May 28, 2009 9:43 AMI am not satisfied with your two options. Because of following reason,
1. First I want to know which one is master table and item table. Because in inner join select query you want to use master table as first and you want to use the item table as second.
Example:
SELECT TAB2A TAB1B TAB1C TAB2D
INTO TABLE ITAB
FROM <MASTER TABLE1> AS TAB1 INNER JOIN <ITEM TABLE2> AS TAB2 ON..........
2. You should not use the INTO CORRESPONDING FIELDS OF ITAB. Instead of this you can change the field order in internal table or in select query.
Example:
Use following way
TYPE: BEGIN OF TY_ITAB
FIELD A
FIELD B
FIELD C
FIELD D
END OF TY_ITAB
SELECT TAB2A TAB1B TAB1C TAB2D
INTO TABLE ITAB
FROM <MASTER TABLE1> AS TAB1 INNER JOIN <ITEM TABLE2> AS TAB2 ON..........
Or , Anyway you are going to use in program only. It will not affect your logic if change the field order in the internal table.
TYPE: BEGIN OF TY_ITAB
FIELD B
FIELD C
FIELD A
FIELD D
END OF TY_ITAB
SELECT TAB1B TAB1C TAB2A TAB2D
INTO TABLE ITAB
FROM <MASTER TABLE1> AS TAB1 INNER JOIN <ITEM TABLE2> AS TAB2 ON..........
3. In inner join query, the order of Where condition also create the perform issue. Because in where condition maximum you try to use all the primary key from <MASTER TABLE1> and <ITEM TABLE2> and field order in where condition should be same order in <MASTER TABLE1> and <ITEM TABLE>.
This are the things you want to take care when you try to use INNER JOIN Query. If you have any clarification please let me know. I will try answer your Questions.
Ravi.
Edited by: RavivarmanP on May 28, 2009 6:55 PM
Maybe you are looking for
-
Ageing analysis for the down payment made to vendors-reg
Dear Gurus, Can anybdoy explains my how to do ageing analysis for the down payment made to various vendors. Thanks C.M.SATHISH KUMAR. [email protected]
-
Hello I am currently using the 2.6.30 kernel with the Intel 2.7.1 driver and no KMS. I think I will make the switch to the newest Intel driver and KMS, but first I would like to know if I have to do anything at all to have KMS after upgrading to .31
-
Saving from Outlook to file - permissions
Never realised I could become frustrated with my Macbook Pro, but here I am! When I open attachments in Outlook and try to save them into a folder, I keep getting a message that says I don't have permission to save the file, with or without renaming
-
How to setup language on iBooks Author
Hi, I just started using iBooks Author and I am starting my book in spanish. Does anyone knows how to change the language? Everything is showing marked in red and I have no way of doing spelling. The only option is English and if I change language
-
Problem setting chapter points at exact locations in timeline
When I go to a place in my timeline where I want to add a chapter point sometimes the point is placed behind or before my desired selection. I expand the timeline to make sure that I'm at the correct location, but nonetheless the chapter point is not