How to include a join in a inner select
I would like to include in my query the field (department_name) from the table (department), how can i use an inner join to get this result in the following query,...
select id,last_name||' '||first_name name, salary, dep_id,demora,
round(abs(count(case when demora>15 then 1 end) over ()
/ count(*) over ()*100-100),2)||'%' avg_delay
from(
select employee_id id, last_name,first_name, salary,department_id dep_id,
case when salary >10000 then 22
when salary <10000 and salary >5000 then 10
else 4
end demora
from employees)
I think this is enough
select employee_id id,last_name||' '||first_name name, salary, d.department_id dept_id ,department_name,
case when salary >10000 then 22
when salary <10000 and salary >5000 then 10
else 4
end demora,
round(abs(count(case when salary>10000 then 1 end) over () / count(*) over ()*100-100),2)||'%' avg_delay
from employees e,departments d
where e.department_id = d.department_id(+);
Similar Messages
-
How to include non-joining records from level one in the lowest level?
As an example the dimension has three levels with data coming from three source tables. The relationships between these tables are zero to many. As a result of this e.g. there are records at the first level that do not join to the second table for level two, i.e. there is a customer entry but the customer has not acquired any products. However, we would like to see in the query for the lowest level also the customers that didn't acquire any products. They are there when there is no filter for the lowest level, but that returns duplicate data. I was hoping I could accomplish this by using outer joins when loading the dimension, but it loads the same as without the outer joins. Hopefully, this trivalized example describes what I am trying to accomplish.
You won't be able to have a true "default" value in the various cascading levels, since there aren't default values in a dynamic cascading parameter. That being said, I've created a sample report in Crystal Reports 2008 that has a Command-driven DCP with '*' values for the 2nd and 3rd levels of my 3-tier DCP and have accounted for them in the record selection criteria. You can find the sample here at https://www.box.net/shared/mav5qp337j
-
How to include Navigational attribute in the selection screen
Hello All,
Can any body please tell me how to include a navigational attribute in the selection screen in BEX?Let´s go step by step.
In your example, you mentioned the characteristic called 0MAT_PLANT. Its navegational attributes are allocated in the same dimension the main characteristic belongs. So 0MRP_CONTRL, as a navegational attr. must be allocated in the same dimension as 0MAT_PLANT.
1) In query designer in Bex (left pane) find the dimension where 0MAT_PLANT is allocated. Find the navegational attr. in the same dimension, 0MRP_CONTRL. Pls verify you are looking to a navegational attribute, activate technical names and the name of the attr must be 0MAT_PLANT__0MRP_CONTRL.
2) Below the attribut (still left pane) you will find a Variable icon (yellow). If you see the "+" symbol, it means that at least one variable exists (standar or not). Open it and check if the variable suits your requeriment to set it in selection screen. If not, create a new one (let me know if you need help with this task).
3) Once you have your variable for the navegational attribute, drag and drop it to the design area (row, column, filter).
4) Verify the order you want this variable to appear from the menu bar: Query properties -> Sequence of Entry Variables.
Hope this helps. Leticia
Edited by: Leticia Laura Locatelli on Oct 1, 2008 10:41 PM -
How to convert maintenance view 'v_t001k_assign' to inner join tables
Dear friends,
I found I could not select the fields of view 'v_t001k_assign' using SQL, and I found there are some tables joined together as below:
T001 MANDT = T001K MANDT
T001 BUKRS = T001K BUKRS
T001K MANDT = TASSIGN_MM_T001W MANDT
T001K BWKEY = TASSIGN_MM_T001W BWKEY
T001W MANDT = TASSIGN_MM_T001W MANDT
T001W WERKS = TASSIGN_MM_T001W WERKS
T001W_EXT MANDT = TASSIGN_MM_T001W MANDT
T001W_EXT WERKS = TASSIGN_MM_T001W WERKS_EXT
So how to convert this maintenance view 'v_t001k_assign' to inner join tables for SQL selection?
Thanks a lot!
Edited by: Qiwei Yin on May 27, 2009 10:35 AMHi,
You should use the 'Search help exit' to select the data for yourself from the database. Go into the search help maintenance screen and press F1 on field 'search help exit'; follow the links. There is actually a pretty good documentation.
Regards, Gerd Rother -
How to include Batch Number in Inventory Counting and Print Countsheet
Hi,
Could someone let us know how to include the batch number from Inventory Counting and include them in the count sheet when printed?
Thank you!
RamonHi Pam......
Try this and modify as you want......
SELECT Distinct T3.[DocDate], T0.[ItemCode], T2.[ItemName], T2.[BatchNum], T0.[Quantity],
T0.[DocEntry], T0.Price, (T0.Price*T0.[Quantity]) As 'Total'
FROM PDN1 T0 inner join OIBT T2 on T2.ItemCode=T0.ItemCode and T2.BaseEntry=T0.DocEntry
INNER JOIN OPDN T3 ON T0.DocEntry = T3.DocEntry
WHERE T2.[BaseType]=20 and T2.[Direction]=0
Regards,
Rahul -
How to include OSTC.rate in this query
How to include OSTC.rate in this query,Im using it for crystal report.
DECLARE @sVAT NVARCHAR(max)
DECLARE @sCess NVARCHAR(max)
DECLARE @sCST NVARCHAR(max)
DECLARE @nDocentry INT
SET @sVAT='1' SET @sCess='7' SET @sCST ='4'
SELECT DocEntry
,DocDate,VehicleNo,Driver,NumAtCard
,Building,Block,Street,City,District,State,Country
,Series,DocNum
,BTinNo,BCstNo,BCeRegNo,BPanNo,BCeRange,BCeComRate,BCeDivision,BEccNo
,Type
,CardName,[Delivery Addr]
,ECCNo,CERange,CERegNo,CEDivis,CEComRate
,PAN,CST,STN
,[Deliver At]
,LineNum
,Dscription,HSNumber,Quantity,Rate,LineTotal,Discount,Vat [VAT],Cess [Cess],Total,GTotal
,TotalExpns
,MfgName
,MFGBuilding,MFGBlock,MFGStreet,MFGDistrict,MFGCity
,MCERegNo,MCERange,MCEDivis,MCEComRate,MPAN,MCST,MSTN
,SupName
,SUPBuilding,SUPBlock,SUPStreet,SUPDistrict,SUPCity
,SCERegNo,SCERange,SCEDivis,SCEComRate,SPAN,SCST,SSTN
, (select substring((select upper(name)+',' from OUBR where isnull(U_SeriesGrp,'')<>'' order by Code FOR XML PATH ('')),1,LEN((select upper(name)+',' from OUBR order by Code FOR XML PATH ('')))-1))[Branches]
FROM
SELECT
/*OBTN.DistNumber*/
INV1.DocEntry
,OINV.DocDate,OINV.U_VehicleNo VehicleNo,OINV.U_Driver Driver,OINV.NumAtCard
,CAST(OLCT.Building AS VARCHAR(255))Building,OLCT.Block,OLCT.Street,OLCT.City,OLCT.County+' - '+OLCT.ZipCode[District],OCST.Name State,OCRY.Name Country
, NNM1.SeriesName [Series], OINV.DocNum
,OLCT.TinNo [BTinNo],OLCT.CstNo [BCstNo],OLCT.CeRegNo [BCeRegNo],OLCT.PanNo [BPanNo],OLCT.CeRange [BCeRange]
,OLCT.CeComRate [BCeComRate],OLCT.CeDivision [BCeDivision],OLCT.EccNo [BEccNo]
,OBTN.U_InvType Type
,OINV.CardName,OINV.Address2[Delivery Addr]
,CE_CRD7.ECCNo,CE_CRD7.CERegNo,CE_CRD7.CERange,CE_CRD7.CEDivis,CE_CRD7.CEComRate
,CRD7.TaxId0[PAN],CRD7.TaxId1[CST],CRD7.TaxId11 [STN]
,OINV.U_Address [Deliver At]
,INV1.LineNum,INV1.ItemCode
,INV1.Dscription,OITM.SWW [HSNumber]
,INV1.Quantity,INV1.PriceBefDi Price,INV1.LineTotal,INV1.Price Rate,(INV1.PriceBefDi-INV1.Price)*INV1.Quantity Discount
,INV4.Vat
,INV4.Cess
,INV1.LineTotal+INV1.VatSum Total
,OINV.DocTotal GTotal
,OINV.TotalExpns
,OBTN.U_MfgName MfgName
,convert(nvarchar(250),MFG_CRD1.Building) MFGBuilding,MFG_CRD1.Block MFGBlock,MFG_CRD1.Street MFGStreet,MFG_CRD1.City MFGCity,MFG_CRD1.ZipCode[MFGDistrict]
,OBTN.U_MCERegNo MCERegNo,OBTN.U_MCERange MCERange,OBTN.U_MCEDivis MCEDivis,OBTN.U_MCEComRate MCEComRate
,OBTN.U_MPAN MPAN,OBTN.U_MCST MCST,OBTN.U_MSTN MSTN
,OBTN.U_SupName SupName
,convert(nvarchar(250),SUP_CRD1.Building) SUPBuilding,SUP_CRD1.Block SUPBlock,SUP_CRD1.Street SUPStreet,SUP_CRD1.City SUPCity,SUP_CRD1.ZipCode[SUPDistrict]
,OBTN.U_SCERegNo SCERegNo,OBTN.U_SCERange SCERange,OBTN.U_SCEDivis SCEDivis,OBTN.U_SCEComRate SCEComRate
,OBTN.U_SPAN SPAN,OBTN.U_SCST SCST,OBTN.U_SSTN SSTN
FROM
OINV
INNER JOIN INV1 ON OINV.DocEntry=INV1.DocEntry
INNER JOIN OITM ON INV1.ItemCode=OITM.ItemCode
INNER JOIN
select
INV4.DocEntry,INV4.LineNum
,CASE WHEN INV4.staType IN (@sVAT,@sCST) THEN sum(INV4.TaxSum) ELSE 0 END Vat
,CASE WHEN INV4.staType=@sCess THEN sum(INV4.TaxSum) ELSE 0 END Cess
from
INV4
where
INV4.DocEntry={?DocKey@} and INV4.RelateType=1
group by INV4.DocEntry,INV4.LineNum,INV4.staType
)INV4 ON INV1.DocEntry=INV4.DocEntry AND INV1.LineNum=INV4.LineNum
INNER JOIN OLCT ON INV1.LocCode=OLCT.Code
INNER JOIN OCST ON OLCT.State=OCST.Code
INNER JOIN OCRY ON OLCT.Country=OCRY.Code and OCST.Country=OCRY.Code
INNER JOIN INV12 ON OINV.DocEntry=INV12.DocEntry
INNER JOIN OITL ON INV1.BaseType=OITL.ApplyType AND INV1.BaseEntry=OITL.ApplyEntry AND INV1.BaseLine=OITL.ApplyLine
INNER JOIN ITL1 ON OITL.LogEntry=ITL1.LogEntry
INNER JOIN OBTN ON ITL1.MdAbsEntry=OBTN.AbsEntry and ITL1.SysNumber=OBTN.SysNumber and ITL1.ItemCode=OBTN.ItemCode
LEFT JOIN OCRD MFG_OCRD ON MFG_OCRD.CardCode=OBTN.U_MfgCode
LEFT JOIN CRD1 MFG_CRD1 ON MFG_OCRD.CardCode=MFG_CRD1.CardCode AND MFG_OCRD.BillToDef=MFG_CRD1.Address and MFG_CRD1.AdresType='B'
LEFT JOIN OCRD SUP_OCRD ON SUP_OCRD.CardCode=OBTN.U_SupCode
LEFT JOIN CRD1 SUP_CRD1 ON SUP_OCRD.CardCode=SUP_CRD1.CardCode AND SUP_OCRD.BillToDef=SUP_CRD1.Address and SUP_CRD1.AdresType='B'
LEFT JOIN NNM1 ON OINV.Series=NNM1.Series
LEFT JOIN CRD7 ON OINV.CardCode=CRD7.CardCode AND CRD7.Address='' AND CRD7.AddrType='S' --Tax Details
LEFT JOIN CRD7 CE_CRD7 ON OINV.CardCode=CE_CRD7.CardCode AND OINV.ShipToCode=CE_CRD7.Address AND CE_CRD7.AddrType='S' -- Central Excise Details
WHERE
INV1.DocEntry={?DocKey@}
)INVOICE
GROUP BY
DocEntry
,DocDate,VehicleNo,Driver,NumAtCard
,Building,Block,Street,City,District,State,Country
,Series,DocNum
,BTinNo,BCstNo,BCeRegNo,BPanNo,BCeRange,BCeComRate,BCeDivision,BEccNo
,Type
,CardName,[Delivery Addr]
,ECCNo,CERange,CERegNo,CEDivis,CEComRate
,PAN,CST,STN
,[Deliver At]
,LineNum
,Dscription,HSNumber,Quantity,Rate,LineTotal,Discount,Vat,Cess,Total,GTotal
,TotalExpns
,MfgName
,MFGBuilding,MFGBlock,MFGStreet,MFGDistrict,MFGCity
,MCERegNo,MCERange,MCEDivis,MCEComRate,MPAN,MCST,MSTN
,SupName
,SUPBuilding,SUPBlock,SUPStreet,SUPDistrict,SUPCity
,SCERegNo,SCERange,SCEDivis,SCEComRate,SPAN,SCST,SSTNYou're double posting ( how to change join condition in this query ) , stop doing that, since you'll only be distracting and diverting by doing so.
Take the time to read the SQL and PL/SQL FAQ @ https://forums.oracle.com/forums/ann.jspa?annID=1535, since you're not even mentioning a database version, while 9i {noformat} != {noformat} 10g {noformat} != {noformat}11g...
Have your DBA trace/tkprof the query, and so on, if you cannot do that yourself.
And then provide the feedback the volunteers, including Ace (Directors)' s need ( and you were very lucky, from that point of view, I think, from looking at both your posts ;) ) -
How to construct Dynamic Join in ABAP?
Hello ALL,
I am typically faced with a situvation where in I need to write a dynamic JOIN SQL statement in ABAP.
For example :
REPORT ZTEST .
PARAMETERS: TBLNAME(50) DEFAULT 'SPFLI'.
DATA: TOTAL_ROWS TYPE P.
SELECT COUNT(*) FROM (TBLNAME) INTO TOTAL_ROWS.
WRITE: / TBLNAME, TOTAL_ROWS.
In the above example, here the fetch from Table is dynamic.
Where as if i have to conisder the following SQL statement which is a normal JOIN statement in ABAP,
select
mara~matnr
marc~werks
from mara
join marc on maramatnr = marcmatnr
into table it_join
where mara~mtart = 'FERT' and
marc~werks = '3000'.
How do i convert this into DYNAMIC JOIN STATEMENT</b> .
Looking forward to your responses.
Thank youHi,
This is from the ABAP keyword help in 6.40, not sure if it works in previous releases or not.
Example
Dynamic specification of the inner joins. The column specification after SELECT is also dynamic.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
DATA: column_syntax TYPE string,
dbtab_syntax TYPE string.
column_syntax = `ccarrname pconnid f~fldate`.
dbtab_syntax = `( ( scarr AS c `
& ` INNER JOIN spfli AS p ON pcarrid = ccarrid`
& ` AND p~cityfrom = p_cityfr`
& ` AND p~cityto = p_cityto )`
& ` INNER JOIN sflight AS f ON fcarrid = pcarrid `
& ` AND fconnid = pconnid )`.
SELECT (column_syntax)
FROM (dbtab_syntax)
INTO CORRESPONDING FIELDS OF TABLE itab.
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Regards
Vilmos -
How to include 0STOCK_VAL in a Query based on APO DataSource?
Hi All,
I have a requirement to include *0STOCK_VAL" from Inventory to the APO InfoCube. But the problem with this is, this particular KeyFigure is not present in the APO hence it cannot be included in the APO DataSource i.e. we cannot get this from the Source System.
I checked the Production system, 0STOCK_VAL InfoObject is avaiable in one of the InfoCube but it is not present in any DSO's. Since it is not present in any of the DSO's we cannot write a Routine to read it from any of the table.
I even thought of including the InfoCube where 0STOCK_VAL is present into a MultiProvider along with the APO InfoCube. I can define the joining condition based on Plant and Material. But if I drill down any other characteristics which are not common in both the InfoCube then we will have a blank line in the Query which is not recommended.
But this KeyFigure is very much needed in the Query.
My question is how to include this in the APO InfoCube or How to get this in the Query with values??
Can anybody please help me on this.
Thanks in advance.
Prasapbihi Matt,
In your example like a transaction was paid for with a payment type of PTAM, then you need all the transaction details. I suppose that all the required transaction details along with payment type PTAM will be loaded into an infoprovider and you run a report on top of this infoprovider. Then for that report you need to have a selection screen variable for Payment Type and if the user enters the payment type PTAM, then he can get all the other transaction details from the infoprovider.
Let me know if i don't understand the requirement correctly.
Hope it helps.... -
How to use outer join condition in my below query.
Hi All,
How to use outer join condition in my below query.
In the table APPS_JP.GEDIS_OFFER_HEADER goh I have more records
in the table APPS_JP.GEDIS_ORDER_BUILDS gob I have less number of records.
I want all the records from APPS_JP.GEDIS_OFFER_HEADER goh
including other conditions.
I have tried goh.OFFER_NO=gob.OFFER_NO(+) but same result.
[code]SELECT GOH.ORIG_SYSTEM,
gsp.USER_NAME,
goh.ORDER_NO,
goh.OMEGA_ORDER_NUMBER,
goh.ORDER_TYPE,
gc.CUSTOMER_ID,
gc.OMEGA_CUSTOMER_NUMBER,
CASE WHEN gc.PRIVATE = 'N' THEN gc.CUSTOMER_NAME ELSE '' END
AS COMPANY_NAME,
goh.ORDER_STATUS,
goh.TOTAL_SELLING_PRICE,
goh.TOTAL_MARGIN,
ga1.ADDRESS1
|| ','
|| ga1.ADDRESS2
|| ','
|| ga1.ADDRESS3
|| ','
|| ga1.POSTAL_CODE
|| ','
|| ga1.CITY
AS SHIPPING_ADDRESS,
ga2.ADDRESS1
|| ','
|| ga2.ADDRESS2
|| ','
|| ga2.ADDRESS3
|| ','
|| ga2.POSTAL_CODE
|| ','
|| ga2.CITY
AS BILLING_ADDRESS,
ga.ADDRESS_ID,
gol.DESCRIPTION,
APPS_JP.TZ.to_local_date (goh.OFFER_DATE, goh.OFFER_DATE_UTC)
AS OFFER_DATE,
gc.LEVEL_8,
goh.NO_OF_BUILDS,
gob.SFDC_ID,
goh.PURCHASE_ORDER_NO AS PO,
gc1.CUSTOMER_NAME AS END_USAGE,
gol.LOB,
goh.TOTAL_MARGIN_PCT,
goh.TOTAL_DISCOUNT,
goh.TOTAL_DISCOUNT_PCT
FROM APPS_JP.GEDIS_OFFER_HEADER goh,
APPS_JP.GEDIS_ORDER_BUILDS gob,
APPS_JP.GEDIS_ORDER_LINES gol,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER gorc,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER ship,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER bill,
APPS_JP.GEDIS_CUSTOMER gc,
APPS_JP.GEDIS_CUSTOMER gc1,
APPS_JP.GEDIS_CONTACT gct,
APPS_JP.GEDIS_ADDRESS ga,
APPS_JP.GEDIS_ADDRESS_NORM ga1,
APPS_JP.GEDIS_ADDRESS_NORM ga2,
(SELECT DISTINCT SALESPERSON_ID, USER_NAME
FROM APPS_JP.GEDIS_SALESPERSON
WHERE SALESPERSON_ID IN
(SELECT TO_NUMBER (COLUMN_VALUE) AS SALESPERSON_ID
FROM TABLE (APPS_GLOBAL.SplitString ('337309'))))
gsp
WHERE goh.ORDER_NO <> 0
AND goh.OFFER_NO <> 0
AND goh.OFFER_NO=gol.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
AND goh.OFFER_NO=gob.OFFER_NO
AND gob.BUILD_NO = 1
AND goh.OFFER_NO = gorc.OFFER_NO
AND gct.CONTACT_ID = gorc.CONTACT_ID
AND ga.CUSTOMER_ID = gc.CUSTOMER_ID
AND ga.PRIMARY = 'Y'
AND goh.LEAD_SALESPERSON=gsp.SALESPERSON_ID
AND goh.OFFER_NO = ship.OFFER_NO
AND ship.RELATION_TYPE = 'SHIP'
AND ga1.ADDRESS_ID = ship.ADDRESS_ID
AND ga1.CUSTOMER_ID = gc1.CUSTOMER_ID
AND goh.OFFER_NO = bill.OFFER_NO
AND bill.RELATION_TYPE = 'BILL'
AND ga2.ADDRESS_ID = bill.ADDRESS_ID
AND goh.OFFER_DATE BETWEEN APPS_JP.TZ.LOCAL_TO_DB_DATE (
SYSDATE - 30
AND APPS_JP.TZ.LOCAL_TO_DB_DATE (SYSDATE)
AND gorc.RELATION_TYPE = 'BASE'
AND gorc.CUSTOMER_ID = gc.CUSTOMER_ID
AND goh.SALES_CHANNEL = gc.SALES_CHANNEL
AND gc.SALES_CHANNEL = 'SMB'
AND goh.LEAD_SALESPERSON IN (goh.CREATED_BY, goh.LEAD_SALESPERSON)
ORDER BY goh.OFFER_NO;[/code]
Please help me how to use this outer join condition.
Thanks in advance.Hi,
If you want all the rows from goh, then you don't want any conditions like goh.OFFER_NO <> 0.
Make all the joins to goh outer joins, and make all conditions that apply to any tables joined to goh (or to tables joined to them) part of the join condition, like this:
FROM APPS_JP.GEDIS_OFFER_HEADER goh
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_BUILDS gob ON gob.OFFER_NO = goh.OFFER_NO
AND gob.BUILD_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_LINES gol ON gol.OFFER_NO = goh.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER
gorc ...
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, do you really need all those tables to show what the problem is? Of course, you need them in tyour real query, but if you understand a solution that only involves 4 or 5 tables, you'll know how to apply it to any number of tables.
Explain, using specific examples, how you get those results from that data.Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ https://forums.oracle.com/message/9362002#9362002 -
How to include dynamic action in bdc
Hi All,
I want to update infotype 17 when an employee has joined through PA40 (Joining action).So i have written a dynamic action for this .But this dynamic ation does not get called in bdc for joining action.
So infotype 17 is not maintained if we do joining through bdc.
I have tried with user-exit zxpadu02 also, calling hr_infotype_operation on saving infotype 0001.But it gives return as 'Employee does not exist'.
Since that infotype 0001 is still not saved.
So what to do.
YogeshHi Amit,
For your information we can call dynamic action from BDC.
go through this link
how to include dynamic actions in bdc -
How to use outer join on 3 tables
how to use outer join on 3 tables
say tables are mkpf,lips and vbrp
mkpf-xblnr = lips-vbeln
lips-vbeln = vbrp-vgbelrefer following querry
select a~bukrs
a~anln1
a~ord42
a~ord43
b~afabe
b~ndabj
b~kaafa
b~aafag
c~kostl
d~afasl
d~ndjar
d~ndper
into corresponding fields of table gt_master
from ( ( anla as a inner join anlc as b
on abukrs = bbukrs
and aanln1 = banln1
and aanln2 = banln2 )
inner join anlz as c
on abukrs = cbukrs
and aanln1 = canln1
and aanln2 = canln2 )
inner join anlb as d
on abukrs = dbukrs
and aanln1 = danln1
and aanln2 = danln2
where a~bukrs in s_comp. -
How many types of joins are there?
how many types of joins are there?
Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:58 PMHi,
Joins are used to fetch data fast from Database tables:
Tables are joined with the proper key fields to fetch the data properly.
If there are no proper key fields between tables don't use Joins;
Important thing is that don't USE JOINS FOR CLUSTER tableslike BSEG and KONV.
Only use for Transparenmt tables.
You can also use joins for the database VIews to fetch the data.
JOINS
... FROM tabref1 INNER JOIN tabref2 ON cond
The data is to be selected from transparent database tables and/or views determined by tabref1 and tabref2. tabref1 and tabref2 each have the same form as in variant 1 or are themselves Join expressions. The keyword INNER does not have to be specified. The database tables or views determined by tabref1 and tabref2 must be recognized by the ABAP Dictionary.
In a relational data structure, it is quite normal for data that belongs together to be split up across several tables to help the process of standardization (see relational databases). To regroup this information into a database query, you can link tables using the join command. This formulates conditions for the columns in the tables involved. The inner join contains all combinations of lines from the database table determined by tabref1 with lines from the table determined by tabref2, whose values together meet the logical condition (join condition) specified using ON>cond.
Inner join between table 1 and table 2, where column D in both tables in the join condition is set the same:
Table 1 Table 2
A B C D D E F G H
a1 b1 c1 1 1 e1 f1 g1 h1
a2 b2 c2 1 3 e2 f2 g2 h2
a3 b3 c3 2 4 e3 f3 g3 h3
a4 b4 c4 3 -
Inner Join
A B C D D E F G H
a1 b1 c1 1 1 e1 f1 g1 h1
a2 b2 c2 1 1 e1 f1 g1 h1
a4 b4 c4 3 3 e2 f2 g2 h2
Example
Output a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
DATA: DATE LIKE SFLIGHT-FLDATE,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID.
SELECT FCARRID FCONNID F~FLDATE
INTO (CARRID, CONNID, DATE)
FROM SFLIGHT AS F INNER JOIN SPFLI AS P
ON FCARRID = PCARRID AND
FCONNID = PCONNID
WHERE P~CITYFROM = 'FRANKFURT'
AND P~CITYTO = 'NEW YORK'
AND F~FLDATE BETWEEN '20010910' AND '20010920'
AND FSEATSOCC < FSEATSMAX.
WRITE: / DATE, CARRID, CONNID.
ENDSELECT.
If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or a table alias.
In order to determine the result of a SELECT command where the FROM clause contains a join, the database system first creates a temporary table containing the lines that meet the ON condition. The WHERE condition is then applied to the temporary table. It does not matter in an inner join whether the condition is in the ON or WHEREclause. The following example returns the same solution as the previous one.
Example
Output of a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
DATA: DATE LIKE SFLIGHT-FLDATE,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID.
SELECT FCARRID FCONNID F~FLDATE
INTO (CARRID, CONNID, DATE)
FROM SFLIGHT AS F INNER JOIN SPFLI AS P
ON FCARRID = PCARRID
WHERE FCONNID = PCONNID
AND P~CITYFROM = 'FRANKFURT'
AND P~CITYTO = 'NEW YORK'
AND F~FLDATE BETWEEN '20010910' AND '20010920'
AND FSEATSOCC < FSEATSMAX.
WRITE: / DATE, CARRID, CONNID.
ENDSELECT.
Since not all of the database systems supported by SAP use the standard syntax for ON conditions, the syntax has been restricted. It only allows those joins that produce the same results on all of the supported database systems:
Only a table or view may appear to the right of the JOIN operator, not another join expression.
Only AND is possible in the ON condition as a logical operator.
Each comparison in the ON condition must contain a field from the right-hand table.
If an outer join occurs in the FROM clause, all the ON conditions must contain at least one "real" JOIN condition (a condition that contains a field from tabref1 amd a field from tabref2.
In some cases, '*' may be specified in the SELECT clause, and an internal table or work area is entered into the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the FROM clause, according to the structure of each table work area. There can then be gaps between table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, not simply by counting the total number of fields. For an example, see below:
Variant 3
... FROM tabref1 LEFT OUTER JOIN tabref2 ON cond
Effect
Selects the data from the transparent database tables and/or views specified in tabref1 and tabref2. tabref1 und tabref2 both have either the same form as in variant 1 or are themselves join expressions. The keyword OUTER can be omitted. The database tables or views specified in tabref1 and tabref2 must be recognized by the ABAP-Dictionary.
In order to determine the result of a SELECT command where the FROM clause contains a left outer join, the database system creates a temporary table containing the lines that meet the ON condition. The remaining fields from the left-hand table (tabref1) are then added to this table, and their corresponding fields from the right-hand table are filled with ZERO values. The system then applies the WHERE condition to the table.
Left outer join between table 1 and table 2 where column D in both tables set the join condition:
Table 1 Table 2
A B C D D E F G H
a1 b1 c1 1 1 e1 f1 g1 h1
a2 b2 c2 1 3 e2 f2 g2 h2
a3 b3 c3 2 4 e3 f3 g3 h3
a4 b4 c4 3 -
Left Outer Join
A B C D D E F G H
a1 b1 c1 1 1 e1 f1 g1 h1
a2 b2 c2 1 1 e1 f1 g1 h1
a3 b3 c3 2 NULL NULL NULL NULL NULL
a4 b4 c4 3 3 e2 f2 g2 h2
Example
Output a list of all custimers with their bookings for October 15th, 2001:
DATA: CUSTOMER TYPE SCUSTOM,
BOOKING TYPE SBOOK.
SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID)
FROM SCUSTOM LEFT OUTER JOIN SBOOK
ON SCUSTOMID = SBOOKCUSTOMID AND
SBOOK~FLDATE = '20011015'
ORDER BY SCUSTOMNAME SBOOKFLDATE.
WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
BOOKING-BOOKID.
ENDSELECT.
If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or using an alias.
Note
For the resulting set of a SELECT command with a left outer join in the FROM clause, it is generally of crucial importance whether a logical condition is in the ON or WHERE condition. Since not all of the database systems supported by SAP themselves support the standard syntax and semantics of the left outer join, the syntax has been restricted to those cases that return the same solution in all database systems:
Only a table or view may come after the JOIN operator, not another join statement.
The only logical operator allowed in the ON condition is AND.
Each comparison in the ON condition must contain a field from the right-hand table.
Comparisons in the WHERE condition must not contain a field from the right-hand table.
The ON condition must contain at least one "real" JOIN condition (a condition in which a field from tabref1 as well as from tabref2 occurs).
Note
In some cases, '*' may be specivied as the field list in the SELECT clause, and an internal table or work area is entered in the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the llen in der FROM clause, according to the structure of each table work area. There can be gaps between the table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, as in the following example (not simply by counting the total number of fields).
Example
Example of a JOIN with more than two tables: Select all flights from Frankfurt to New York between September 10th and 20th, 2001 where there are available places, and display the name of the airline.
DATA: BEGIN OF WA,
FLIGHT TYPE SFLIGHT,
PFLI TYPE SPFLI,
CARR TYPE SCARR,
END OF WA.
SELECT * INTO WA
FROM ( SFLIGHT AS F INNER JOIN SPFLI AS P
ON FCARRID = PCARRID AND
FCONNID = PCONNID )
INNER JOIN SCARR AS C
ON FCARRID = CCARRID
WHERE P~CITYFROM = 'FRANKFURT'
AND P~CITYTO = 'NEW YORK'
AND F~FLDATE BETWEEN '20010910' AND '20010920'
AND FSEATSOCC < FSEATSMAX.
WRITE: / WA-CARR-CARRNAME, WA-FLIGHT-FLDATE, WA-FLIGHT-CARRID,
WA-FLIGHT-CONNID.
ENDSELECT. -
How to include old invoices in the invoice list
How to Include old billing documents in the invoice list.
TO be more clear:-
I created 20 invoices in the monthof JAN
I maintained the factory calender in the payer master in the month of Feb 1st and created 10 more invoices in this month.
So the system is considering only the invocies which were generated after I maintained the factory calender (Only feb invoices).
Is there any process to include the previous invoicies (Jan invoices) also to get include in the invoice list.
Help me in this regards.
Regards,
Mallesh.It is not possible.
Regards,
Rajesh Banka -
How to include a jsp page in another jsp jsp page
hi,
i m trying to include a jsp page name "header.jsp" into one jsp page name"selectattribute.jsp" i m using these commands in "selectattribute.jsp"
<%@include file "header.jsp"%> bcz both these jsp page are C:\program files\tomcat 4.0\webapps\examples\jsp\Poject\
but the problem is that , i m invoking this jsp page "selectattribute.jsp" from a servlet reportcontroller.java using REQUEST DISPATCHER.
the servlet is in
C:\Program files\tomcat 4.0\webapps\examples\WEB-INF\classes\Project\
i want to know how to include some other jsp page in a jsp page and how to invoke applet from jsp page when that particular jsp page is being invoked by servlet.
plz help
manishuse this for including in your selectattribute.jsp
<jsp:include page="header.jsp" flush="true"/>
I never tried calling an applet. I think you can write the code for calling the applet in a javabean method and call the method in the jsp -
How do I effectively join the Macs to the AD?
Hi. First, I must qualify that I am NOT a network individual. Some of the research I've done, I've managed to follow, but I don't have the technical know-how to fully understand it all. I desparately need help, please.
I work in a medium-sized environment, about 50 PCs and we employ Windows Server 2003. I've been charged with making 10 or so Macs work in Active Directory. Our Mac users constantly run into expiring netword passwords every 30 days (extending this is not an option because of the nature of the work).
How do I effectively join the Macs to the AD and allow changes to network passwords from the Mac? So far, for every Mac users, I've used SMB to connect to server files/folders. But when the users' password expires, they are 1) not notified that their passwords are expiring and 2) are not able to change their passwords from their Macs when their passwords expires. I've tried binding my Mac to the AD and used a free software called ADMon to monitor my own expiring network password. And that's proving useless because it's monitoring the local password for the Mac instead of the network password.
Mac users are mostly on OS Lion, one Mac user on Snow Leopard.
I would really appreciate any help/advice you can provide.
Thanks!AD is still broken with Lion as at 10.7.2. May want to read this thread to try the workarounds, mainly Page 5, while Apple sort it out.
https://discussions.apple.com/thread/3198558?start=60&tstart=0
Maybe you are looking for
-
Serial number creation at the time of GI
Dear Experts, I want to create sreial number and equipment number simultaneously at the time of GI please hel m out with customization settings. Thanks Warm regards Rahul
-
Dear Sir What is the T-Code to reverse F-37 entry (Customer down payment request) Thanks Sanjay
-
How to add coustom fonts in Adobe formscental ?
Hi, I want to add coustom fonts in my form, which i have created in adobe formscentral. But here is limited fonts. So how i add different fonts in this software ? (because different client want add there own fonts in there forms). Regards, Susanta
-
Personalization Server and DBMS
Hi, Have someone tried to install the Personalization Server with container managed persistence (cmp) in another DB than Cloudscape ??? Can the Personalization Server be installed with Oracle and cmp ? And for instance MS SQL Server ? Thanks in advan
-
Cannot download an app I've received via mail as a present
My sister sent me an app as a gift via the App Store but when I use the link in the mail I get directed to the App Store and nothing happens. Am I the only one in this situation?! Not only, I tryed to send an app as gift to her and she has the same p