Query to Join three queries
Hi,
I have three queries as follows. I want to write a single query by using these three queries. can any one please help me out to write the query.
Query 1:
SELECT a_name,
b_item_typ_cd,
item_num,
a_m_name,
DECODE(RTRIM(LTRIM(t_clasfn_cd)),NULL,NULL,
‘X’|| t_clasfn_cd) t_clasfn_cd,
in_splt_pct,
item_ind
FROM ABC.a_cmpnt_w
WHERE b_item_typ_cd IN ('A','U','I')
ORDER BY DECODE(b_item_typ_cd,'A','A'||b_item_typ_cd,
'U','B'||b_item_typ_cd,
'C'||b_item_typ_cd);
Query 2:
SELECT a_name,
b_item_typ_cd,
item_num,
a_m_name,
DECODE(RTRIM(LTRIM(t_clasfn_cd)),NULL,NULL,
‘X’|| t_clasfn_cd) t_clasfn_cd,
in_splt_pct,
item_ind
FROM ABC.a_cmpnt_w
WHERE b_item_typ_cd IN ('U','I')
ORDER BY DECODE(b_item_typ_cd,'U','A'||b_item_typ_cd,
'B'||b_item_typ_cd);
Query 3:
SELECT a.item_num
FROM ABC.item a, ABC.X2_PRDT_LN b
WHERE a. PRDT_LN_CD= b. PRDT_LN_CD
AND b. t_clasfn_cd = t_clasfn_cd
so I want to write a single query .
Thanks.
Try this..
SELECT a_name,
b_item_typ_cd,
item_num,
a_m_name,
DECODE(RTRIM(LTRIM(t_clasfn_cd)),NULL,NULL,
‘X’|| t_clasfn_cd) t_clasfn_cd,
in_splt_pct,
item_ind
FROM ABC.a_cmpnt_w
WHERE b_item_typ_cd IN ('A','U','I')
--ORDER BY DECODE(b_item_typ_cd,'A','A'||b_item_typ_cd,'U','B'||b_item_typ_cd,'C'||b_item_typ_cd);
union all
SELECT a_name,
b_item_typ_cd,
item_num,
a_m_name,
DECODE(RTRIM(LTRIM(t_clasfn_cd)),NULL,NULL,
‘X’|| t_clasfn_cd) t_clasfn_cd,
in_splt_pct,
item_ind
FROM ABC.a_cmpnt_w
WHERE b_item_typ_cd IN ('U','I')
--ORDER BY DECODE(b_item_typ_cd,'U','A'||b_item_typ_cd,'B'||b_item_typ_cd);
union all
SELECT NULL,NULL,a.item_num,NULL,NULL,NULL,NULL
FROM ABC.item a, ABC.X2_PRDT_LN b
WHERE a. PRDT_LN_CD= b. PRDT_LN_CD
AND b. t_clasfn_cd = t_clasfn_cd)U have to remove the order by clause from indiviual queruies,but u can use order by at the end..
And for union u must have same no of columns in each query..
Regards
Umesh
Similar Messages
-
How to join three queries in sap bw
Hi,
I have to create one report as combination of three reports.
This report will be combination of three Report
ZQ_Ap_005 -- ZCFIAPCO
ZQ_AR_008 u20130FIAR_003
ZQ_AP_016u2014ZCFIAPPU
This condition I have to join
Company Code (005 & 016) = Trading Partner (from ZQ_AR_008)
Vendor (ZQ_AP_005 & 016) = Company code (from ZQ_AR_008)
I can not use infoset because using 3.5 version. And in 3.5 can not include infocube in infoset.
Any suggestion.Hi Namah
you need not do any java scripting for this. The command is enough to take care of your situation.
Perhaps an example can help you. Suppose you have Query1, Query2 & Query3 and Button1 and Button 2. Button 3
For Query1, through the item properties, set Visiblility=Visible, for Query2, set Visibility=Hidden.
Query3, set Visibility=Hidden.
This will take care of your initial situation.
Now, take button1, assign the command 'Set webitem properties'. In the command settings, set item binding=query1, and then in the next page of command settings set visibility=hidden. Now, click the button -Next COmmand-> Insert -assign the command 'set webitem properties' once again. Here, select the item binding as query2, then in the command settings, set visibilty=visible. What you have done now is assigning 2 commands to the same button, both getting trigerred with a single click.
Now, this command setting will take care of making query1 hidden and query 2 visible.
Similarly, do the settings for the button 2, with query1=visible and query2=hidden.
Now, the result will be that on clicking button1 and button2, you can toggle between your queries.
Hope this helps.. -
How to join three tables?
I have used this query to join three tables but it displays an error : field vbak-vbeln is unknown.
please help me out..
SELECT vbak-vbeln vbak-bstnk vbap-matnr vbap-zmeng makt-maktx
INTO CORRESPONDING FIELDs OF TABLE itab FROM vbak
inner JOIN vbap ON vbak-vbeln eq vbap-vbeln
inner JOIN makt ON vbap-matnr eq makt-matnr
WHERE vbak-bstnk = s_bstnk.Hi mohan kumar ,
just follow the Syntax
SELECT FLD1 FLD2 FLD3 FLD4 FLD5 INTO CORRESPONDING FIELDS OF TABLE ITAB FROM TABLE1 INNER JOIN TABLE2 ON
TABLE1FLD1 = TABLE2FLD1 INNER JOIN TABLE3 ON TABLE2FLD2 = TABLE3FLD2 INNER JOIN TABL4 ON TABLE3FLD3 = TABLE4FLD3
WHERE FLD1 = 'AA'
Hope this may be helpful.
Please reward points if found ok.
Thanks and regards,
Rajeshwar. -
Left join query with join of three tables
I'm trying to build a query which has me stumped. Most of the query is fairly straightforward but I've run into an issue I'm not sure how to solve.
Background:
We have actions stored in i_action.
We have the available attributes for each type of action. The available attributes for each action are described in shared_action_attribute. Each type of action may have up to three attributes or none at all.
We have the values stored for the attributes in i_attribute_value.
A written example:
We have a transfer action (action_code B4). The entry of the B4 action into i_action records the fact that the transfer occurred and the date on which it occurred. The available attributes for a transfer action are the receiving function code, the receiving unit number, and the transfer reason code. These available attribute types and their order are stored in shared_action_attribute. The actual values of the attributes for a specific transfer action are stored in i_attribute_value.
Now i_action and i_attribute_value can be directly linked through action_seq in i_action and ia_action_seq in i_attribute_value. A left join built between these two tables provides results for all actions (including actions which have no attributes) and attribute values (see query 1 below).
There are two issues. First, I only want the first two attributes. In order to specify the first two attributes, I also have to link i_attribute_value to shared_action_attribute (which is where the order is stored). I can build a simple query (without the left join) linking the three tables but then actions with no attributes would be excluded from my result set (see query 2 below).
The second issue is that I would actually like one row returned for each action with first_attribute and second_attribute as columns instead of two rows.
The final query will be used to create a materialized view.
Here are the tables and examples of what's stored in them:
TABLE i_action
Name Type
ACTION_SEQ NUMBER(10)
ACTION_DATE DATE
ACTION_CODE VARCHAR2(3)
DELETED VARCHAR2(1)
EXAMPLE ROWS
ACTION_SEQ ACTION_DATE ACTION_CODE DELETED
45765668 09-OCT-09 B2 A
45765670 09-OCT-09 BA A
45765672 09-OCT-09 B6 A
45765673 09-OCT-09 B4 A
45765674 09-OCT-09 G1 A
45765675 09-OCT-09 M3 A
TABLE i_attribute_value
Name Type
IA_ACTION_SEQ NUMBER(10)
SACTATT_SACT_CODE VARCHAR2(3)
SACTATT_SAT_TYPE VARCHAR2(3)
VALUE VARCHAR2(50)
EXAMPLE ROWS
IA_ACTION_SEQ SACTATT_SACT_CODE SACTATT_SAT_TYPE VALUE
45765668 B2 ACO 37B
45765670 BA ROA D
45765670 BA ROR P
45765672 B6 CAT C
45765673 B4 RFC E
45765673 B4 TRC P
45765673 B4 RUN 7
45765674 G1 SS 23567
45765674 G1 ASG W
TABLE shared_action_attribute
Name Type
SACT_CODE VARCHAR2(3)
SAT_TYPE VARCHAR2(3)
ORDER NUMBER(2)
TITLE VARCHAR2(60)
EXAMPLE ROWS
SACT_CODE SAT_TYPE ORDER TITLE
B2 ACO 1 Office code
BA ROR 1 Reason for reopen
BA ROA 2 Reopen authority
B6 CAT 1 Category
B4 RFC 1 Receiving function code
B4 RUN 2 Receiving unit code
B4 TRC 3 Transfer reason code
G1 SS 1 Staff sequence
G1 ASG 2 Assignment reason
QUERY 1:
This is my current query along with its results. Most of it is straightforward select but one column is populated using the last_value analytical function (thanks to you guys). The last column in the below view stores the attribute value. What I want is to replace that single column with two columns named first_attribute and second_attribute and to eliminate any other attributes.
SELECT ia.action_seq, ia.action_date, ia.action_code cod,
NVL
(LAST_VALUE (CASE
WHEN ia.action_code = 'G1'
AND iav.sactatt_sat_type = 'SS'
THEN VALUE
WHEN ia.action_code IN ('A0', 'A1')
THEN '67089'
END IGNORE NULLS
) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
ia.serial_number, ia.action_seq),
'67089'
) staff_seq,
value
FROM i_action ia LEFT JOIN i_attribute_value iav
ON iav.ia_action_seq = ia.action_seq
WHERE ia.deleted = 'A';
ACTION_SEQ ACTION_DA COD STAFF_SEQ VALUE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 D
45765670 09-OCT-09 BA 67089 P
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E
45765673 09-OCT-09 B4 67089 P
45765673 09-OCT-09 B4 67089 7
45765674 09-OCT-09 G1 23567 23567
45765674 09-OCT-09 G1 23567 W
45765675 09-OCT-09 M3 23567
QUERY 2:
This query limits to the first two attributes but it also drops actions which have no attributes and it still creates multiple rows for each action instead of a single row with two columns for the attributes.
SELECT ia.action_seq, ia.action_date, ia.action_code cod,
NVL
(LAST_VALUE (CASE
WHEN ia.action_code = 'G1'
AND iav.sactatt_sat_type = 'SS'
THEN VALUE
WHEN ia.action_code IN ('A0', 'A1')
THEN '67089'
END IGNORE NULLS
) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
ia.serial_number, ia.action_seq),
'67089'
) staff_seq,
value
FROM shared_action_attribute saa, ims_action ia, ims_attribute_value iav
WHERE iav.ia_action_seq = ia.action_seq
AND iav.sactatt_sact_code = saa.sact_code
AND iav.sactatt_sat_type = saa.sat_type
AND saa.display_order IN ('1','2')
AND ia.deleted = 'A';
ACTION_SEQ ACTION_DA COD VALUE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 D
45765670 09-OCT-09 BA 67089 P
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E
45765673 09-OCT-09 B4 67089 7
45765674 09-OCT-09 G1 23567 23567
45765674 09-OCT-09 G1 23567 W
I found this pretty complex to try to write out - I hope I've been clear.
Thanks so much!Ok, here's more information with a simplified question. I figured out the syntax for building my query with the three tables. My final query returns multiple rows (multiple attributes per action). Instead of multiple rows, I'd like two columns (first_attribute, and second_attribute) in a single row (I only need the first two attributes).
Here's the action table:
CREATE TABLE I_ACTION
ACTION_SEQ NUMBER(10) NOT NULL,
ACTION_DATE DATE,
ACTION_CODE VARCHAR2(3 BYTE) NOT NULL,
DELETED VARCHAR2(1 BYTE),
);With the following rows added:
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765668, '09-oct-2009', 'B2', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765670, '09-oct-2009', 'BA', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765672, '09-oct-2009', 'B6', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765673, '09-oct-2009', 'B4', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765674, '09-oct-2009', 'G1', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765675, '09-oct-2009', 'M3', 'A');
COMMIT;The attribute table is:
CREATE TABLE I_ATTRIBUTE_VALUE
IA_ACTION_SEQ NUMBER(10) NOT NULL,
SACTATT_SACT_CODE VARCHAR2(3 BYTE) NOT NULL,
SACTATT_SAT_TYPE VARCHAR2(3 BYTE) NOT NULL,
VALUE VARCHAR2(50 BYTE),
);With the following rows:
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765668, 'B2', 'ACO', '37B');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765670, 'BA', 'ROR', 'P');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765670, 'BA', 'ROA', 'D');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765672, 'B6', 'CAT', 'C');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765673, 'B4', 'RFC', 'E');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765673, 'B4', 'RUN', '7');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765673, 'B4', 'TRC', 'P');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765674, 'G1', 'SS', '23567');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765674, 'G1', 'ASG', 'W');
COMMIT;And finally, the shared table:
CREATE TABLE SHARED_ACTION_ATTRIBUTE
SACT_CODE VARCHAR2(3 BYTE) NOT NULL,
SAT_TYPE VARCHAR2(3 BYTE) NOT NULL,
TITLE VARCHAR2(25 BYTE) NOT NULL,
DISPLAY_ORDER NUMBER(2) NOT NULL
);With the following rows:
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B4', 'RFC', 'Y', 'Rcv. Function Code', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B6', 'CAT', 'Y', 'Category', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('G1', 'SS', 'Y', 'Staff Name', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B2', 'ACO', 'Y', '"Other" Office Code', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B4', 'RUN', 'Y', 'Receiving Unit Number', 2);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B6', 'LEP', 'N', 'LEP Issue/Sub Category', 2);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B4', 'TRC', 'Y', 'Transfer Reason Code', 3);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B6', 'NEP', 'N', 'NEP Issue', 3);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('G1', 'ASG', 'Y', 'Assignment Reason', 2);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B2', 'MSN', 'S', 'Machine Serial Number', 3);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('BA', 'ROR', 'Y', 'Reopen Reason', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('BA', 'ROA', 'Y', 'Reopen Authority', 2);
COMMIT;Now, this is my current query (it's changed from my first post):
SELECT ia.action_seq, ia.ici_charge_inquiry_seq, ia.action_date,
ia.serial_number, ia.reporting_office, ia.reporting_function,
ia.reporting_unit, ia.action_code, ia.machine_serial_number,
NVL
(LAST_VALUE (CASE
WHEN ia.action_code = 'G1'
THEN VALUE
WHEN ia.action_code IN ('A0', 'A1')
THEN '67089'
END IGNORE NULLS
) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
ia.serial_number, ia.action_seq),
'67089'
) staff_seq,
(CASE
WHEN display_order = '1'
THEN VALUE
END) first_attribute,
(CASE
WHEN display_order = '2'
THEN VALUE
END) second_attribute
FROM ims_action ia
LEFT JOIN ims_attribute_value iav
ON iav.ia_action_seq = ia.action_seq
LEFT JOIN shared_action_attribute
ON sactatt_sact_code = sact_code
AND sactatt_sat_type = sat_type
WHERE ia.deleted = 'A';Which gives me the following results:
ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 D
45765670 09-OCT-09 BA 67089 P
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E
45765673 09-OCT-09 B4 67089 7
45765673 09-OCT-09 B4 67089
45765674 09-OCT-09 G1 23567 W
45765674 09-OCT-09 G1 23567 23567
45765675 09-OCT-09 M3 23567 The result I WANT is similar but I want the two separate attribute columns on one row as such:
ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 P D
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E 7
45765674 09-OCT-09 G1 23567 23567 W
45765675 09-OCT-09 M3 23567 Thanks so much! -
How to send three attachments using three queries in a single email using sp_senddbmail
Hi All,
I have three scripts for extracting permissions at server,database & object level.Now how do i can execute all three queries and send multiple attachments in a single email using sp_senddbmail.I have done this before for single queries but not multiple
queries. Kindly suggest.
Regards
RahulHi All,
The requirement was that i had three different queries for listing permissions at server,database and object level.I wanted to build an solution to email results in attachment to user.
However i have managed to do this with SSIS Package.I was curious to know if it can be done without SSIS.
Thanks you all for your time and effort for this.
Rahul
It can be done without SSIS
Just have a procedure to return three query results as a single resultset. Then use sp_send_dbmail to execute query and send results as a email
See
http://blogs.msdn.com/b/sqlagent/archive/2010/11/03/sql-database-mail-send-t-sql-results-by-email.aspx
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
I have to join three tables but i m getting error as given below:
Error i m getting-
Syntax error(missing operator) in query expression 'invoice.INVOICE_NO=inv_ent_main.INVOICE_NO INNER JOIN invrate ON invrate.INVOICE_NO=inv_ent_main.INVOICE_N'.
My Query is-
"select inv_ent_main.EXPORTER,inv_ent_main.INVOICE_NO,inv_ent_main.INVOICE_DATE,inv_ent_main.BALE_COUNT,inv_ent_main.TOTAL_AMOUNT,inv_ent_main.BALE_COUNT,inv_ent_main.TOTAL_PIECES,inv_ent_main.TOTAL_AREA,invoice.ORDER_NO,invoice.OTHER_REF,invoice.CONSIGN1,invoice.CONSIGN2,invoice.CONSIGN3,invoice.CONSIGN4,invoice.CONSIGN5,invoice.DLV_TERMS,invoice.PAYMENT_TERMS,invoice.PRE_CARRIAGE,invoice.PR_CARRIER,invoice.DESTINATION,invoice.COUNTRY_DESTINATION,invoice.VESS_FLIGHT,invoice.PORT_LOAD,invoice.PORT_DSCH,invoice.MARK1,invoice.MARK2,invoice.CURRENCY,invoice.GOODS_DESCRIPTION,invoice.CFB,invoice.GROSS_WEIGHT,invoice.NET_WEIGHT,invoice.WOOL,invoice.COTTON
from inv_ent_main INNER JOIN invoice ON invoice.INVOICE_NO = inv_ent_main.INVOICE_NO INNER JOIN invrate ON invrate.INVOICE_NO = inv_ent_main.INVOICE_NO";
MCA,LUCKNOW.The last character in the error message has missing "O" when compare to the actual query you have posted. Please rerun it an verify or you can try the below query. You need to post DDL for all the 3 tables so that we can test.
select
inv_ent_main.EXPORTER,
inv_ent_main.INVOICE_NO,
inv_ent_main.INVOICE_DATE,
inv_ent_main.BALE_COUNT,
inv_ent_main.TOTAL_AMOUNT,
inv_ent_main.BALE_COUNT,
inv_ent_main.TOTAL_PIECES,
inv_ent_main.TOTAL_AREA,
invoice.ORDER_NO,
invoice.OTHER_REF,
invoice.CONSIGN1,
invoice.CONSIGN2,
invoice.CONSIGN3,
invoice.CONSIGN4,
invoice.CONSIGN5,
invoice.DLV_TERMS,
invoice.PAYMENT_TERMS,
invoice.PRE_CARRIAGE,
invoice.PR_CARRIER,
invoice.DESTINATION,
invoice.COUNTRY_DESTINATION,
invoice.VESS_FLIGHT,
invoice.PORT_LOAD,
invoice.PORT_DSCH,
invoice.MARK1,
invoice.MARK2,
invoice.CURRENCY,
invoice.GOODS_DESCRIPTION,
invoice.CFB,
invoice.GROSS_WEIGHT,
invoice.NET_WEIGHT,
invoice.WOOL,
invoice.COTTON from inv_ent_main
INNER JOIN invoice ON invoice.INVOICE_NO = inv_ent_main.INVOICE_NO
INNER JOIN invrate ON invrate.INVOICE_NO = inv_ent_main.INVOICE_NO
Regards, RSingh -
Getting no result by joining three tables in BMM
Hi all,
I have a requirement where I have a fact table and two ailas dimension table.
Let say fact is w_account_f and dimension ailas dim_w_account_d_trans and dim_w_account_d_sal of w_account_d table
I have join in physical layer
w_account_f ----> dim_w_account_d_trans with forgin key join
w_account_f ----> dim_w_account_d_sal with forgin key join
In BMM i have join these three table but given content level filter in dimension like
dim_w_account_d_trans.tans_col = 'active'
dim_w_account_d_sal.sal > 4000
when i am trying to pull the report from all three table
w_account_f, dim_w_account_d_trans, dim_w_account_d_sal
its not giving any result where as when i trying to pull report with fact any one dimension its giving me result.
can anyone help me in finding the soulting how to get the data by joining all these three tables.Hi,
Take the physical query with all three tables selected. Run the query in sql developer, remove the joins one by one and check where it fails. Modify the rpd model accordingly.
Regards,
Dpka -
How can I join to queries?
Hello all,
I would like to ask if there is a way to join two queries into another new one.
I've been trying including two structures from two queries (always from the same infoprovider) but the result is not what I'm looking for.
Has anyone any idea of how to do this?
Thank you very much,
Carlos HinestrosaHi Michael,
Thanks for your answer. I know there are lots of funtionalities in excel but I need the result of the query as simple as it is to work with it in SEM Balanced Scorecard / Management Cockpit because SEM does not support many BEX funtionalities.
I make some calculations in one query and others in the other query, and I need the result of thoese calculations to make further calculations in a new query.
I was trying to create a query but the dialog box only allows to create a query from a cube.
Thanks,
Carlos Hinestrosa -
Hi,
Can somebody please help me join the 2 queries I am posting below. I am having a hard time with them. There are some common tables in both of them.
Query 1 :
select "LAST_NAME"||', '||"FIRST_NAME" from
TV_LABCASE c join TV_LABASSIGN a on c."CASE_KEY"=a."CASE_KEY"
JOIN TV_REPTNAME n on a."EXAM_KEY"= n."EXAM_KEY"
join TV_LABNAME LN ON n."NAME_KEY"=ln."NAME_KEY"
WHERE "LAB_CASE"='10-000747';
Query2:
select "ITEM_TYPE" from
TV_LABCASE c join TV_LABASSIGN a on c."CASE_KEY"=a."CASE_KEY"
join TV_ITASSIGN n on a."EXAM_KEY" = n."EXAM_KEY"
join TV_LABITEM ln on n."EVIDENCE_CONTROL_NUMBER" = ln."EVIDENCE_CONTROL_NUMBER"
WHERE "LAB_CASE"='10-000747';
Please help me take the common ones out and make it a combined query. Both singel queries work without any error.
Thanks in advance!!!Thanks a lot, it works, just a small mistake with the variables.
select "LAST_NAME"||', '||"FIRST_NAME", "ITEM_TYPE" from
TV_LABCASE c join TV_LABASSIGN a on c."CASE_KEY"=a."CASE_KEY"
JOIN TV_REPTNAME p on a."EXAM_KEY"= p."EXAM_KEY"
join TV_ITASSIGN n on a."EXAM_KEY" = n."EXAM_KEY"
join TV_LABITEM ln on n."EVIDENCE_CONTROL_NUMBER" = ln."EVIDENCE_CONTROL_NUMBER"
join TV_LABNAME Lname ON p."NAME_KEY"=Lname."NAME_KEY"
WHERE "LAB_CASE"='10-000747';
This works fine
But when I executed 2nd query, I have 2 results
Blood
Blood
For the first query it is
Smith Jones
When I combine I get "Smith Jones " Blood.
But I should get 2 rows with the same name and Type "Blood" -
Hello All
Can someone tell me how to join two queries without using a multicube
or infoprovider option.
First Query has x, y, z fields
Second Query has x,a,b fields
now can i join the first and second query by the common field x.
Without changing the infoprovider or multicube design,i want to join
the query at the query level.
I want to join the two queries using common field x and then replace
the second query a, b fields with y, z fields data of query1.
RegardsHi Santosh.
If you want to use the workbook solution you should create one sheet for each query.
Lets assume that you have X in column A in both sheets and Y and Z in column B and C in sheet1. For the columns D and E on sheet1 you should insert some VB-code that gets the data from sheet2 where X equals X from sheet1. Here is an example:
=IF(ISNA(VLOOKUP(A1;sheet2!$A$1:$B$200;2;FALSE));"";(VLOOKUP(A1;sheet2!$A$1:$B$200;2;FALSE)))
You will have to use this code for all the rows along the column. I.e. if A has an output of 200 rows, you will need the code from line 1->200. You will also have to consider that the results may be more in the future.
Hope it helps.
BR
Stefan -
One Query or Two liinked Queries
hi experts
i want to know what is the better in performance in the report builder is to create one single query with join 2 master and details tables
or
create 2 queries one for each table and link them by datalink
thanksI don't think you will notice a HUGE difference in performance.
But, I think it would be easier to have everything in one main query then control it with grouping.
Edited by: Kurzweil4 on Sep 8, 2010 3:30 PM -
Joining two queries with Visual Composer
Hallo,
I was working with visual composer to join two queries with the distinct operator. But on my table view, when i linked it with the distinct operator, i get only the key element customer (customer, customer_ext_key, customer_key). These are the queries that i want join:
Query 1:
Customer
Net Sales
Query 2:
Customer
Billed Quantity
What i want to see is the following result:
Customer
Net Sales
Billed Quantity
Can anybody help me with this problem?
Greeting,
Murat.Hallo,
I was working with visual composer to join two queries with the distinct operator. But on my table view, when i linked it with the distinct operator, i get only the key element customer (customer, customer_ext_key, customer_key). These are the queries that i want join:
Query 1:
Customer
Net Sales
Query 2:
Customer
Billed Quantity
What i want to see is the following result:
Customer
Net Sales
Billed Quantity
Can anybody help me with this problem?
Greeting,
Murat. -
How to build a query to join on two tables without mapping
I did Automatic mapping by the workbench Directofield mapping with the table and java object.
Wanted to build a simple join query by joining on the same field on both the tables.Not the sql query through the toplink using expression builder.
Please help.............
Spent one full day for this................Thanks Don for the reply,sorry to bug you,but i need help.....
SELECT A.AGNCY_C,
A.TYPE_C,
A.RESN_C,
A.S_TYPE_C,
A.SUB_ID_C,
A.RY_C
FROM RATING A, REF B
WHERE A.ID_C = B._ID_C
AND A.ALPHA_C = B.ALPHA_C
AND A.EFF_D >= B.MATURITY_D
This is the real query i was talking about.I did mapping automatically through the workbench,generated java classes also throught the workbench.
Now they don't want to execute the raw sql.They wanted to get all the RATING objects with the where condition.
So how to build a query by using toplink.
tried your example
ExpressionBuilder builder = new ExpressionBuilder();
Expression creditRating = builder.getTable("RATING").getField("ID_C");
Expression issue_ref = builder.getTable("REF").getField("ID_C");
Expression join = creditRating.equal(issue_ref);
I am getting java.lang.OutOfMemoryError
error.
I selected the option generate classes and descriptors
from the tables (RATING,REF).,so it created the classes and dscriptors automatically.
In Database script for the table RATING like this
ALTER TABLE RATING ADD (
CONSTRAINT RATING_F1 FOREIGN KEY (ID_C, ALPHA_C)
REFERENCES REF (ID_C,ALPHA_C));
I think when i generate descriptor automatically it is keeping this association.
Please help me......... -
Query to join 2 tables by interval of value
Hi all
I need your help in creating a query to join 2 tables by interval of values.
The thing i want to d ois like this: i have 2 tables the first one containing list of serial number and the secon is containing interval of serial number (startnumber and end number) and other information like the user creating the serial number.
I want to list all serial numbers from the first table and the user creating each serial number from the second one if the serial number is between each interval of the second table.
here is an example>
SQL> create table test1 (code varchar2(1), serial number);
Table created.
SQL> create table test2 (requester varchar2(10),startno number, endno number);
Table created.
SQL> insert into test1 values('A',1);
1 row created.
SQL> insert into test1 values('B',3);
1 row created.
SQL> insert into test1 values('C',8);
1 row created.
SQL> insert into test1 values('D',12);
1 row created.
SQL> insert into test1 values('E',20);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into test2 values('TATA',1,5);
1 row created.
SQL> insert into test2 values('TOTO',6,10);
1 row created.
SQL> commit;
Commit complete.
The result i want to get are:
TESt1.CODE TEST2.REQUESTER
A TATA
B TATA
C TOTO
D null
E nullUse outer join:
select code,
requester
from test1,
test2
where serial between startno(+) and endno(+)
order by code
C REQUESTER
A TATA
B TATA
C TOTO
D
E
SQL> SY. -
Need complex query with joins and AGGREGATE functions.
Hello Everyone ;
Good Morning to all ;
I have 3 tables with 2 lakhs record. I need to check query performance.. How CBO rewrites my query in materialized view ?
I want to make complex join with AGGREGATE FUNCTION.
my table details
SQL> select from tab;*
TNAME TABTYPE CLUSTERID
DEPT TABLE
PAYROLL TABLE
EMP TABLE
SQL> desc emp
Name
EID
ENAME
EDOB
EGENDER
EQUAL
EGRADUATION
EDESIGNATION
ELEVEL
EDOMAIN_ID
EMOB_NO
SQL> desc dept
Name
EID
DNAME
DMANAGER
DCONTACT_NO
DPROJ_NAME
SQL> desc payroll
Name
EID
PF_NO
SAL_ACC_NO
SALARY
BONUS
I want to make complex query with joins and AGGREGATE functions.
Dept names are : IT , ITES , Accounts , Mgmt , Hr
GRADUATIONS are : Engineering , Arts , Accounts , business_applications
I want to select records who are working in IT and ITES and graduation should be "Engineering"
salary > 20000 and < = 22800 and bonus > 1000 and <= 1999 with count for males and females Separately ;
Please help me to make a such complex query with joins ..
Thanks in advance ..
Edited by: 969352 on May 25, 2013 11:34 AM969352 wrote:
why do you avoid providing requested & NEEDED details?I do NOT understand what do you expect ?
My Goal is :
1. When executing my own query i need to check expalin plan.please proceed to do so
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9010.htm#SQLRF01601
2. IF i enable query rewrite option .. i want to check explain plan ( how optimizer rewrites my query ) ? please proceed to do so
http://docs.oracle.com/cd/E11882_01/server.112/e16638/ex_plan.htm#PFGRF009
3. My only aim is QUERY PERFORMANCE with QUERY REWRITE clause in materialized view.It is an admirable goal.
Best Wishes on your quest for performance improvements.
Maybe you are looking for
-
Error while exporting a table - EXP-00091
I am doing an export of a table. The table has 1000838 rows. After the export is completed, when I checked the log - it said Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production With the Partitioning option JServer Release 9
-
I would like to ask a question .So i have a problem, my problem is that way before when I created my apple ID I didnt pay attention in my secret answers neither the emails, and whats even worse I gave my pass to my family members so they all use my a
-
Apple ID area refuses to delete an address from my profile.
I click "delete address" and it confirms it will delete, but it's still there. I have another address on file.
-
Pixel Bender and the Droste Effect plugin from Adobe Labs
I was just wanting to know if the above plugin can be used with PSE 11, since PSE 11 is based on CS5, and CS5 is what the plugin is designed for.....? It would be a genuine blast to work with a filter like that; I can think of a dozen different pictu
-
What is dynamic user variable??/
how can I can get some information regarding this??????