Related to Join
I have 2 tables and i am trying to join them
SQL> select * from t_tldn_allocated ;
ID TLDN_FROM TLDN_TO QTY MSC_ID PURPOSE_ID
165 9370682000 9370682249 250 160 1
171 9336798000 9336798249 250 160 1
177 9351029000 9351029249 250 160 1
183 9337912000 9337912249 250 160 1
189 9341520000 9341520249 250 160 1
195 9351030000 9351030999 1000 160 1
201 9332712000 9332712249 250 160 1
7 rows selected.
SQL> select * from t_trn_allocated;
ID TRN_FROM TRN_TO QTY MSC_ID
139 9370393000 9370393999 1000 160
SQL> select a.TLDN_FROM,a.TLDN_TO,b.TRN_FROM,b.TRN_TO from t_tldn_allocated a join t_trn_allocated b on a.msc_id=b.msc_id;
TLDN_FROM TLDN_TO TRN_FROM TRN_TO
9370682000 9370682249 9370393000 9370393999
9336798000 9336798249 9370393000 9370393999
9351029000 9351029249 9370393000 9370393999
9337912000 9337912249 9370393000 9370393999
9341520000 9341520249 9370393000 9370393999
9351030000 9351030999 9370393000 9370393999
9332712000 9332712249 9370393000 9370393999
but the TRN_FROM and TRN_TO are getting repeated i dont want the duplicates but only single and for rest of the rows i want the values to be 0 can any one provide me a query to do so Thanks in advance
You can use decode to do this:
select a.tldn_from
,a.tldn_to
,decode(rownum,1,b.trn_from,0)
,decode(rownum,1,b.trn_to,0)
from t_tldn_allocated a
join t_trn_allocated b on a.msc_id = b.msc_id;The decode returns for the first row (rownum=1) the value from table b, for all other rows it returns 0.
Rene
Similar Messages
-
Hi All,
I needed some help figuring out a particular join.
I have three tables ;
NPIProjects (alias npip) table which contains ID
testGrades (alias tg) table which contains the fields -----id , ProductGrade
NewModels (alias nm) which contains the ------ ID, testgradesID( foreign key) and generic
Each testgrade can have any number of entries in the NewModels. I need to get the min(generic) for each testgrades.
I am using SQLX
SELECT XMLELEMENT ("Parts", XMLAGG ( XMLELEMENT ("Part", XMLELEMENT ("Attributes", XMLELEMENT ("Attribute", XMLAttributes ('PartType' AS "Name", 'I' AS "Value")),
XMLELEMENT ("Attribute", XMLAttributes ('Generic' AS "Name", nm.Generic AS "Value")) ) ) ) ) ) ORDER BY tg.id), XMLELEMENT ("TestGradesPrimaryKeys", XMLAGG ( XMLELEMENT ("TestGradesPrimaryKey", tg.id) ORDER BY tg.ID) ) )
INTO v_PartsXML
FROM NPIProjects npip
JOIN TestGrades tg ON (npip.ID = tg.NPIProjectID)
JOIN NewModels nm ON (tg.ID = nm.TestGradesID)
WHERE npip.ID = p_NPIProjectID ;
Right now I have a TestGradeID 1800 with Product Grade A and 2 NewModels(1900 & 1901) entries associated with this TestGradeID. When I run the above query it comes back with 2 rows with the same information and same tg.ID. This is becuase I am refering to the Generic field in the newmodels table and the newmodels table has 2 records associated with this TestgradeID.
How can I get the results of a distinct/min generic for each unique grade irrespective of the number of entries it has in the newmodels table.
Thanks,
AvantikaHi All.
This is the output I am getting. If you notice the same stuff is repeated twice. This is because there are 2 entries in the Newmodels table for the same testgrades ID. I am looking to get just one record back for each testgrade irrespective of how many ever records exists in the NewModels Table.
Currently getting:
<Parts>
<Part>
<Attributes>
<Attribute Name="PartType" Value="I"/>
<Attribute Name="Generic" Value="ADS2"/>
</Attributes>
</Part>
<Part>
<Attributes>
<Attribute Name="PartType" Value="I"/>
<Attribute Name="Generic" Value="ADS2"/>
</Attributes>
</Part>
<TestGradesPrimaryKeys>
<TestGradesPrimaryKey>1840</TestGradesPrimaryKey>
<TestGradesPrimaryKey>1840</TestGradesPrimaryKey>
</TestGradesPrimaryKeys>
</Parts>
Looking for:
<Parts>
<Part>
<Attributes>
<Attribute Name="PartType" Value="I"/>
<Attribute Name="Generic" Value="ADS2"/>
</Attributes>
</Part>
<TestGradesPrimaryKeys>
<TestGradesPrimaryKey>1840</TestGradesPrimaryKey>
</TestGradesPrimaryKeys>
</Parts>
Please suggest the best approach I could use.
Thanks,
Avantika -
Hi all,
I have a dought ...related to join and all entries
Which one will be the better as per performance prospective :
1>For all entries
or
2> using inner join condition
i am combining 2 tables ...
but in my where clause is having 6-7 condition if i used inner join concept...
Please let me know thanks for the help...in advance
regards
AmitCheck Re: Multiple Table Join instead of Nested Selects? I wrote a program that compares the performance of a join against for all entries. The join won. But the best thing to do is for you test and compare both methods for your particular situation.
In a select, the most important factor is the use of an index.
Rob -
No more smooth/corner option when joining endpoints in CS5?
OK, I've looked around for the answer. Where did the smooth/corner dialog box go in CS5? Yes, my points are aligned.
ThanksThere are two updates related to Join functionality in CS5.
1. There is a new functionality to join two anchor points of same or different paths by using Cmd/Ctrl+J. You don't even need to select the anchor points - just select the path in full and press Cmd/Ctrl+J. The closest anchor points are detected and joined. A second press of Cmd/Ctrl+J would join the remaining ends. Example:
To join the anchor points of your choice, just select those anchor points and press Cmd/Ctrl+J. Example:
2. The earlier shortcut to join two overlapping anchor points is different in CS5. It used to be Cmd/Ctrl+J, but now it is Cmd/Ctrl+Shift+Opt/Alt+J. The method remains the same i.e. the two anchor point have to be overlapping and selected.
Hope this helps.
Neeraj -
hi
i am new to sap , i dont no about inner join in abap coding
plz send me some notes or coding.
thank u.
your regrads
divya.hi
use this links
INNER JOIN and OUTER JOINhttp://help.sap.com/erp2005_ehp_03/helpdata/EN/cf/21ec77446011d189700000e8322d00/frameset.htm
JOINED TABLES
http://help.sap.com/erp2005_ehp_03/helpdata/EN/0f/49bd6a5d5049edba7b3afe6c7956e3/frameset.htm
u will find all thins related to joins with example and how to use it
Cheers
Snehi
Edited by: snehi chouhan on Jul 25, 2008 9:45 AM -
Relations and failover / restart
Hi -
I'd be grateful if someone could point me in the right direction - it feels like I'm missing something here.
If an agent in the EPN correlates between two streams by introducing relations and joining on them, how should we handle node restarts?
For example, if a relation stores the last hour's set of events on a stream, how do we best repopulate it when the node is restarted?
As we are running on a cluster, just the single node, or the entire cluster may be restarted.
Background
We run CEP on a cluster (not HA mode). There is surplus capacity in the cluster - if we lose a server or a JVM, the Coherence data mastered there will repartition to another node. The 'insertion' of a row into a local Coherence backing store is the trigger for the events into the CEP - so data repartitioning to a node will cause the CEP on that node to process the data through the EPN (usually reprocess it because it's already been processed elsewhere).
I am trying to understand how to use relations (and continuous queries, which have similar properties) in this type of environment - how to maintain or rebuild state after a restart.
-thanks, BarneyHi Barney,
Technically what you want is an "upstream backup" - this can be achieved by using coherence as a durable source of events and replay the events from Coherence in the case of a restart. If your relation moves in time then the other approach is to use servers in parallel to maintain continuity - in the simple case you have two servers processing the same set of events but only one outputing results (co-ordinated by any one of the HA adapters that we ship). If you restart one of these then the other node will output the correct sequence until the relation window has been rebuilt in the newly started server, at that point you can restart the other server.
andy -
About join in Orale Lite...
hi, I wonder how many join statemetns can be included in select SQL statement under ADOCE environment..
I also want to know is it possible multiple join statesments with JDBC if ADOCE connection couldn't fetch rows with multiple join statements..
Thank you in advance..hi
use this links
INNER JOIN and OUTER JOINhttp://help.sap.com/erp2005_ehp_03/helpdata/EN/cf/21ec77446011d189700000e8322d00/frameset.htm
JOINED TABLES
http://help.sap.com/erp2005_ehp_03/helpdata/EN/0f/49bd6a5d5049edba7b3afe6c7956e3/frameset.htm
u will find all thins related to joins with example and how to use it
Cheers
Snehi
Edited by: snehi chouhan on Jul 25, 2008 9:45 AM -
I am trying to get special text to appear on the pick list when the oitm.qrygroup2 field is Yes. I have 2 operator fields:
f_398 is the text field with the special text, link to f_400
f_399 is a database field, table is oitm, field is property 2, related to field_233 (system variable field for item #)
calculation field:
f_400 is a formula field, f_399=="yes"
as i understand it, when f_398 is true (the link to f_400 triggers a true value) the special text will appear.
The problem i'm facing is regardless the setting in oitm.qrygroup2 the result is always No even when the property value is actually Yes.
I'm guessing my related to joining is not working properly.
any ideas?Try f_399=='Y' for the formula.
Thanks,
Gordon -
How to use multiple xmlforest() function within xmlagg() function
I need to create following XML structure by reading multiple tables from DB .
The tables are relational and joined by keys.
<Invoice>
<CaseOrdrId>0000022359</CaseOrdrId>
<Id>100065117</Id>
<Prescription>
<CaseOrdrItmId>0000005684</CaseOrdrItmId>
<RxId>1104900686</RxId>
<Prescriber>
<CasePartyIdDEA>0000000000</CasePartyIdDEA>
<CasePartyIdNPI>0000000000</CasePartyIdNPI>
<CasePartyIdSLic>0000000000</CasePartyIdSLic>
</Prescriber>
<PatInfo>
<CasePartyId>0000000000</CasePartyId>
</PatInfo>
</Prescription>
</Invoice>
<Invoice>
<Invoice>
<Invoice>
<Invoice>
<Invoice> tag can repeat 5times , So,I am using xmlagg().
To create the tree structure within <Invoice> I am using multiple xmlforest().
But getting error : SQL Error: ORA-06553: PLS-306: wrong number or types of arguments in call to 'SYS_IXMLAGG' . code added today marked in yellow.
Any help on this would be really helpful.Hi , I could fix the previous issue with xmlagg().
My query is as follows :
select
xmlelement( "Response", xmlforest( b.StatusCode as "StatusCode", b.StatusMessage as "StatusMessage",
b.ServiceAction as "ServiceAction",
select
xmlforest( a.id as "Id", a.ExternalId as "ExternalId", a.Source as "Source", a.UserID as "UserID", xmlforest(b.id as
"Id")"Note", xmlforest(
select
Xmlforest(P.Case_Party_Id As "CasePartyId",Xmlelement("CaseGeoAddrId",S.Address_Id )as "Address"
from
v44139.party p,
v44139.patient_address s
where
p.case_party_id = s.case_party_id
and p.party_id_type_cde = 'MBR'
AND s.individual_agn_id = 0
) as "Membership")"Group",
select
xmlagg(xmlelement("Invoice",xmlelement( "CaseOrdrId",d.case_order_id),
xmlelement("Id" ,d.invoice_nbr) ,xmlelement("Prescription",
xmlforest(e.case_order_item_id as "CaseOrdrItmId", e.rx_nbr as "RxId"),
xmlelement("Prescriber",
xmlforest(169629 as "CasePartyIdDEA", 169630 as "CasePartyIdNPI",169631
as "CasePartyIdSLic")),xmlelement("PatInfo",xmlforest(e.case_party_id as "CasePartyId") )) ) )
--AS ID
from
v44139.patient_order d ,
v44139.order_rx e
where
d.case_id = a.id
and d.case_order_id = e.case_order_id
as "Invoice"
from
select
'142' as id,
'CMRT' as source,
'V44042' as userid,
'EMG-7788' as externalid ,
361 as case_party_id
from
dual
a
"Case") ) as "XML_QUERY"
from
select
200 as statuscode,
'SUCCESS' as statusmessage,
'0000000000' as id,
'Update' serviceaction
from
dual
b;
===============================================================================================
The result is as follows :
<Response><StatusCode>200</StatusCode><StatusMessage>SUCCESS</StatusMessage><ServiceAction>Update</ServiceAction><Case><Id>142</Id><ExternalId>EMG-7788</ExternalId><Source>CMRT</Source><UserID>V44042</UserID><Note><Id>0000000000</Id></Note><Group><Membership><CasePartyId>382</CasePartyId><Address><CaseGeoAddrId>144</CaseGeoAddrId></Address></Membership></Group_*><Invoice><Invoice><*_CaseOrdrId>202</CaseOrdrId><Id>999999993 </Id><Prescription><CaseOrdrItmId>105</CaseOrdrItmId><RxId>1118800008</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382 </CasePartyId></PatInfo></Prescription></Invoice><Invoice><CaseOrdrId>203</CaseOrdrId><Id>825478795 </Id><Prescription><CaseOrdrItmId>106</CaseOrdrItmId><RxId>1118800005</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382 </CasePartyId></PatInfo></Prescription></Invoice><Invoice><CaseOrdrId>204</CaseOrdrId><Id>999999992 </Id><Prescription><CaseOrdrItmId>107</CaseOrdrItmId><RxId>1118800007</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382 </CasePartyId></PatInfo></Prescription></Invoice><Invoice><CaseOrdrId>205</CaseOrdrId><Id>999999991 </Id><Prescription><CaseOrdrItmId>108</CaseOrdrItmId><RxId>1118800006</RxId><Prescriber><CasePartyIdDEA>169629</CasePartyIdDEA><CasePartyIdNPI>169630</CasePartyIdNPI><CasePartyIdSLic>169631</CasePartyIdSLic></Prescriber><PatInfo><CasePartyId>382 </CasePartyId></PatInfo></Prescription></Invoice></Invoice></Case></Response>
The ISSUE : <Invoice> tag repeating twice in 3 rd line . How to correct this ? -
Error in OBIEE Reports.ORA-01445
When making some formula or adding new columns,I am getting the following Err..
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1445, message: ORA-01445: cannot select ROWID from, or sample, a join view without a key-preserved table at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
Its something related to joins.Can anyone Help.
Edited by: Darwin S on Aug 22, 2009 8:48 PMyou should post this on the OBIEE forum Business Intelligence Suite Enterprise Edition
-
Error in OBIEE:Oracle Error code: 1445
When making some formula or adding new columns,I am getting the following Err..
State: HY000. Code: 10058. NQODBC SQL_STATE: HY000 nQSError: 10058 A general error has occurred. nQSError: 17001 Oracle Error code: 1445, message: ORA-01445: cannot select ROWID from, or sample, a join view without a key-preserved table at OCI call OCIStmtExecute. nQSError: 17010 SQL statement preparation failed. (HY000)
Its something related to joins.Can anyone Help.
Edited by: Darwin S on Aug 22, 2009 8:48 PMORA-01445: cannot select ROWID from a join view without a key-preserved table
Cause: A SELECT statement attempted to select ROWIDs from a view derived from a join operation. Because the rows selected in the view do not correspond to underlying physical records, no ROWIDs can be returned.
Action: Remove ROWID from the view selection clause, then re-execute the statement.
ROWID isn't really an intressting column when doing BI...
regards
John
http://obiee101.blogspot.com/ -
In PL / Sql generated report file, format excel:
<Row>
<Cell> …</CELL>
<Cell> …</CELL>
</ROW>
How can insert in this file picture?
Is it possible in this file to put binary code, and that when opening a file Excel showed the picture.
Thanks
Edited by: user10777774 on 29.07.2010 11:04I don't have any ready-made example.
I was just saying it's possible in PL/SQL because basically, Office Open XML (OOX) files are archives containing various parts about properties, data, embedded resources etc.
So, in essence, "all" you have to do is :
- convert some XML raw extract of data to the SpreadsheetML format expected by OOX
- generate the necessary properties and relations files
- join resources (images...)
- zip all in a single archive with .xlsx extension
Here's an article introducing briefly the format :
http://www.developerfusion.com/article/6170/read-and-write-open-xml-files-ms-office-2007/ -
Master-Detail Form in Form6i Developer
First of All Hi to all Respected Gurus.
I am stuck in a very basic element and that is Primary-Key/Foreign-Key relation. I am trying to create a Master-Detail Form based on following structure. Records in Master Table and Child Table are saving (inserting) but Primary Key of Master Table is not saving (inserting) as "Foreign Key" in Detail Table.
Here is Table Structure(s)
Master Table Name : MGTC_EDM
CREATE TABLE MGTC_EDM
EDM_ID NUMBER, -- PRIMARY KEY
BILLING_DATE DATE,
CONSTRAINT PK_MGTCEDM_EDMID PRIMARY KEY (EDM_ID)
CHILD TABLE : MGTC_EDD
CREATE TABLE MGTC_EDD
EDD_ID NUMBER; -- PRIMARY KEY
EDM_ID NUMBER; -- FOREIGN KEY RELATION WITH MGTC_EDM
MEM_ID NUMBER;
AMOUNT NUMBER;
CONSTRAINT PK_MGTCEDD_EDDID PRIMARY KEY (EDD_ID),
CONSTRAINT FK_MGTCEDD_EDMID FOREIGN KEY (EDM_ID)
REFERENCES MGTC_EDM (EDM_ID)
TRIGGER OF "BEFORE_INSERT" IS APPLIED ON BOTH TABLES TO AUTO-POPULATE INCREMENTAL ID
IN FORM6I, I'VE APPLIED A 'KEY_NEXT_ITEM' TRIGGER ON BILLING_DATE FIELD OF MASTER TABLE TO COMMIT THE RECORD AND TO MOVE THE CURSOR TOWARDS DETAIL BLOCK
AND THERE ARE NO MORE TRIGGERS IN THE FORM.
AS CURSOR MOVES TOWARDS DETAIL BLOCK, RECORD IN MASTER TABLE SAVES (COMMITTED) ON AUTO AND WHEN I PRESS "SAVE" BUTTON TO SAVE THE RECORD IN CHILD FORM DETAIL TABLE ALSO COMMITTED
BUT WHEN I PRESS F8 TO EXECUTE THE QUERY ONLY MASTER RECORD SHOWS AND NO RECORD SHOWS IN THE DETAIL TABLE. WHEN I CHECKED IN DETAIL TABLE IN TOAD, IT FOUND THAT PRIMARY KEY OF MASTER TABLE (EDM_ID) NOT SAVED IN DETAIL TABLE.
PLEASE HELP.Dear Mr. O.Developer, Many thanks for your reply.
Yes, I've created relationship. Relationship exist in Master_Block and below is the detail
Relationship Name = MGTC_EDM_MGT_EDD
Relation Type = Join
Detail Data Block = MGTC_EDD
Join Condition = MGTC_EDD.EDM_ID = MGTC_EDM.EDM_ID
Delete Record Behavior = Non Isolated
Prevent Masterless Operations = No
Deferred = No
Automatic Query = No -
Master-detail: check changes in detail when navigation in master
Dear friends,
forms 6i oracle 9i.
I have a master and a detail block, changes in detail block can only be made in a non-database-field.
For saving a procedure do_save is called where values from non-database-fields are calculated and then put into database field.
For realizing that any changes where made I created another non-database-field in a control block which is set to 1 in when-validate-item-trigger of detail.non-database-field.
When closing the form I simply check the status of my control.item und if necessary call the dó_save procedure.
I now want to have same functionality when navigating through master-block, for example with key-down.
I tried to use the master on_populate_detail trigger:
--snip
do_check_item_changed;
IF ( (:EVM_A_ARTIKEL.H_MANDANT is not null) or (:EVM_A_ARTIKEL.ABTEILG_ID is not null) or (:EVM_A_ARTIKEL.ARTTYP_ID is not null) or (:EVM_A_ARTIKEL.ARTIKEL_ID is not null) ) THEN
rel_id := Find_Relation('EVM_A_ARTIKEL.EVM_A_ARTIKEL_EVM_JN_A_L');
Query_Master_Details(rel_id, 'EVM_JN_A_L');
--snip
but at this time the detail block seems to be empty.
Has anybody an idea where's the right place to put my
checking procedure?
Thanks for help
SilkeHallo,
Do you mean this?
relation type Join
detail datablock evm_jn_a_l (this block
itself is based
on a join)
join condition EVM_JN_A_L.H_MANDANT = EVM_A_ARTIKEL.H_MANDANT AND
EVM_JN_A_L.ABTEILG_ID = EVM_A_ARTIKEL.ABTEILG_ID AND
EVM_JN_A_L.ARTTYP_ID = EVM_A_ARTIKEL.ARTTYP_ID AND
EVM_JN_A_L.ARTIKEL_ID = EVM_A_ARTIKEL.ARTIKEL_ID
behavion when deleting not isolated
hinder masteless actions no
coordination no
automatic query no
Silke -
1-many CMP2.0 Container Managed Persistence
Sorry for posting this again, but there did not seem to be any replies.
I have noticed a very strange phenomena in 1-many container managed relationships in the J2EESDK1.3.
In 1-many Container Managed Relationships, the J2SDKEE1.3 actually generates 3 tables rather than 2. The first table is the 1 side table. The second table is the many side table. The third table is a relation table joining the 1 side table and many side table. This relation table has 2 fields, one is the primary key of the many side table (this field becomes the primary key of the relation table) and the other field is the primary key of the one side table.
This generation of a new table for 1-many relationships is giving me a headache because these tables now form a (0 or 1) - many relationship now.
Is this defined as part of the EJB2.0 spec or is this a J2SDKEE1.3 dependant feature?I'm afraid I can't give you an exact answer to this question, but it seems to me that this is a work-around in order not to create the relationshis in the DB.
I have noticed this behaviour as well, only I have found another problem with it. The relationship table doesn't seem to survive an undeploy or server restart. Do you have the same problem?
I think that maybe a commercial application server with a database for which it has been optimized will not show this behaviour, but will define the relationship as meta-data in the DB.
Maybe you are looking for
-
Change color of the showDetailItem in panelTabbed in 11G
Dear All, I have to change the color of showDetailItem in panelTabbed from gray to dark blue. But when I am trying to set the color from style the color of whole panel gets changed. I want to change the color of of the tab only. Please help its Urgen
-
Unsupported file formats for Adobe Pro 8
I am trying to convert a group of files ranging from .xsl to .doc types. Adobe is saying these are not supported. I see .dwg, .txt, .jpeg, etc. but no .doc or .xls format. I know adobe should support these document types as I have seen it on other
-
Hi Friends, I need a logic for the below mentioned thing, for all entries in i_tab i need to check makt table with makt-matnr = i_tab-matnr. if subrc = 0. need to determine eknam Join tables marc and t024 . fill the i_tab-eknam field with the val
-
RW DVDs aren't rewritable!
Hi When I burn a -RW or +RW DVD my Mac does this as a read only file (whic defeats the whole point of the exercise) I have tried going into Applications/Utilities/Disk Utilities and then clicking on the erase tab but the erase button won't highlight.
-
Can't read messages moved to Trash folder
When I try to read the messages in my Trash folder all I see is the very top of one line of text. Each subsequent line has an asterisk at each end but no text in between them.