Join 2 tables with 2 criteria
hello
i'm trying to join 2 tables with 2 criteria
one criteria is "numero de matricule" and the other is "date"
in one table i have many times the same "matricule" it depends of "date de validité" validity date
ex table 1
n°mat - periode - montant
1 -31-12-2013 - 100
table2
n°mat -periode - nom - adresse
1 -
31-12-2013 - gerard - 12 RUE X
1- 31/12/2012-GERARD - 2AVENUE Z
how can i join those tow table
thak you for your help, i'm a french beginner
select *
from table1 as a
join table2 as b
on a.n°mat = b.n°mat
and a.periode = b.periode
sqldevelop.wordpress.com
Saeid, check this out and reply there if you're interested:
http://social.technet.microsoft.com/Forums/en-US/a2e22d61-7c32-43f2-900e-d9d6325fa26d/needed-more-power-pivot-answerers?forum=sqlkjpowerpivotforexcel
Thank you for all your contributions!
Ed Price, Azure & Power BI Customer Program Manager (Blog,
Small Basic,
Wiki Ninjas,
Wiki)
Answer an interesting question?
Create a wiki article about it!
Similar Messages
-
Join fact table with higher dimension level
how do i join fact tables with higher dimension levels with discoverer?
fact with detail at level C
measure X
dimension with
D->C->B->A
E->C
level
A B C
1------1------1
2------2------1
3------2------1
join between fact X and dimension level C
X=3*C because of sum(X) in discoverer and 3xC in dimension
is there a way to get correct values for X without creating a dimension like
D->C
E->another way of asking this is whether you can create a summary table in Discoverer at a higher level than a dimension's fundamental grain. In other words - the summary examples in the documentation all describe leaving out one or more of your dimensions... they are either left in or completely taken out. But, some of the most effective summarization occurs when you summarize daily data to a monthly level. Assuming that I have a sales table (at a daily level, and a key value sales_date), and a table date_dim (primary key sales_date), I would like to create a summary sales_month_summary where the sales are grouped on month_year (which is a field in the sales_date table).
How is this done? I suspect that we can't use the date_dim table with the summary (due to the problems noted by the poster above). Do we have to create another table "month_dim"? Do we have to fold all of the desired date attributes (month, quarter, year) into the summary? Obviously we'd like to re-use all of the pertinent already existing date items (quarter, month, year, etc.), not recreate them over again, which would result in essentially two sets of items in the EUL. [One used for this month summary, and another used for the detail.]
I searched the forum - someone asked this same question back in 2000 - there was no answer provided.
The only other thought I have is to "snowflake" the date_dim into two tables and two folders, one at a date level, another at the month level. Then the detail tables can connect to date_dim (which is linked to month_dim), while the summary data can connect directly to month_dim. -
Left outer join 3 tables with where-statement
Hi folks,
I hope you can understand (and maybe solve) my problem.
Generally I try to left outer join three tables. The third table is used for a WHERE-statement.
The three table structures are the following:
table 1 (user)
user1 | key
table 2 (detail)
key | ID
table 3 (header)
ID | user2
...and I want to achieve the following structure (as example filled with data):
user | key | ID
|-----|----
xy | a | 001
xy | b | #
z | b | #
The clue ist the usage of the third table. I need the table to set user1 and user2 equal (WHERE) but there are two problems:
1) Obviously I can't left outer join two tables with each other. In this case I already used the 'key' of table 1 to join it with the 'key' of table 2. So I can't left outer join the 'ID' of table 2 with the 'ID' of table 3. Error message that I can only left outer join a table once. Any proposals?
2) I have to include a WHERE to equal user1 with user2. But I am not allowed to use the user2 from table 3 because of the left outer join.
I tried this coding:
SELECT auser1 akey b~id INTO TABLE itab FROM ( table1 AS a
LEFT OUTER JOIN table2 AS b ON akey = bkey )
LEFT OUTER JOIN table3 AS c ON bID = cID )
WHERE auser1 = cuser2.
I would really appreciate your help.
Regards
MrclSpdlIF you want to join a DB table with an internal table, you need to use the 'FOR ALL ENTRIES' statement.
select dbfields
into table itab2
from dbtab
for all entries in itab
where dbfield1 = itab-field1.
This will get you a second internal table with all the corresponding data for the first selection. You can then join them with a loop through the first table and a read table on the second table (for 1 - 1 relation) or a nested loop statement on both tables (for 1 - N relation). Make itab a hashed table when using read table with key, use a sorted table if you need to loop without key access.
Regards,
Freek -
Joining a table with all_tab_columns
How is it possible to join a table with the tab_columns?
The query im trying to establish is that in my table they are 12 columns with months names. So under an input variable im trying to return the required values with the selected months. The only way i could think of to get the months to connect with the tab_columns table.
Any suggestion is really appreciated
SELECT bust,
Sum(jan) JAN,
Sum(feb) FEB,
Sum(mar) MAR,
Sum(apr) APR,
Sum(may) MAY,
Sum(jun) JUN,
Sum(jul) JUL,
Sum(aug) AUG,
Sum(sep) SEP,
Sum(oct) OCT,
Sum(nov) NOV,
Sum(DEC) DECC
FROM budget a,all_tab_columns b
WHERE vsl_code = 4602
AND code = 1
AND year=2013
AND account_code='30'
AND b.table_name='BUDGET'
AND b.column_name IN
(SELECT column_name
FROM (SELECT Column_name, ROWNUM r
FROM all_tab_columns b
WHERE table_name = 'BUDGET'
AND Column_id BETWEEN 3 AND 14
ORDER BY column_id)
WHERE r BETWEEN 2 AND 3 ) --Returns February,March
group by bust;Sorry, I don't understand what you're trying to do or why you think you need to join to all_tab_columns. Perhaps you could post the definition of the budget table, some sample data, and the results you're hoping to see.
Without that, I don't see why you can't just do this:
SELECT bust,
Sum(jan) JAN,
Sum(feb) FEB,
Sum(mar) MAR,
Sum(apr) APR,
Sum(may) MAY,
Sum(jun) JUN,
Sum(jul) JUL,
Sum(aug) AUG,
Sum(sep) SEP,
Sum(oct) OCT,
Sum(nov) NOV,
Sum(DEC) DECC
FROM budget a
WHERE vsl_code = 4602
AND code = 1
AND year=2013
AND account_code='30'
group by bust; -
Hi,
My doubt is can I join the table with view in the below where clause condition in the query. If yes, the below query will take 4 hrs to execute it. Can I do the below query to write as simplest?
SELECT *
FROM uabpymt p, uavlsum l
WHERE uabpymt_appl_ind = 'N'
AND uabpymt_amount > 5
AND l.uavlsum_balance < 0
AND l.uavlsum_cust_code = p.uabpymt_cust_code
AND l.uavlsum_prem_code = p.uabpymt_prem_codeuavlsum ---view
uabpymt ---table
The view script below:
CREATE OR REPLACE VIEW UAVLSUM
(UAVLSUM_CUST_CODE, UAVLSUM_PREM_CODE, UAVLSUM_AMOUNT, UAVLSUM_BALANCE)
AS
SELECT cust_code,
prem_code,
SUM(amount),
SUM(balance)
FROM (
SELECT uabopen_cust_code cust_code,
uabopen_prem_code prem_code,
uabopen_billed_chg amount,
uabopen_balance balance
FROM uimsmgr.uabopen
UNION ALL
SELECT uabpymt_cust_code,
uabpymt_prem_code,
uabpymt_amount * -1,
uabpymt_balance * -1
FROM uimsmgr.uabpymt
UNION ALL
SELECT uabadje_cust_code,
uabadje_prem_code,
uabadje_balance,
to_number(0)
FROM uimsmgr.uabadje
WHERE uabadje_balance <> 0)
GROUP BY cust_code,
prem_codeFind the below explain plan output which we get from the execute the query
STATEMENT_ID TIMESTAMP REMARKS OPERATION OPTIONS OBJECT_NODE OBJECT_OWNER OBJECT_NAME OBJECT_INSTANCE OBJECT_TYPE OPTIMIZER
16/01/2009 05:57:24 SELECT STATEMENT RULE
16/01/2009 05:57:24 FILTER
16/01/2009 05:57:24 SORT GROUP BY
16/01/2009 05:57:24 TABLE ACCESS BY INDEX ROWID UIMSMGR UABPYMT 1
16/01/2009 05:57:24 NESTED LOOPS
16/01/2009 05:57:24 VIEW UIMSMGR 3
16/01/2009 05:57:24 UNION-ALL
16/01/2009 05:57:24 TABLE ACCESS FULL UIMSMGR UABOPEN 4
16/01/2009 05:57:24 TABLE ACCESS FULL UIMSMGR UABPYMT 5
16/01/2009 05:57:24 TABLE ACCESS FULL UIMSMGR UABADJE 6
16/01/2009 05:57:24 INDEX RANGE SCAN UIMSMGR UABPYMT_CUST_PREM_INDEX NON-UNIQUE
Index column:
Table name :UABPYMT
Column Name
UABPYMT_APPL_IND
UABPYMT_APPROVED_IND
UABPYMT_PYMT_DATE
UABPYMT_SOURCE
UABPYMT_ORIGIN
UABPYMT_CUST_CODE
UABPYMT_PREM_CODE
UABPYMT_PYMT_DATE
UABPYMT_AR_TRANS
UABPYMT_GL_IND
UABPYMT_GL_POST_DATE
UABPYMT_AR_TRANS -
Join Istore table with AR tables
Hi Gurus,
How to join ibe_msites_b table with AR table. I am trying to get list of all customers from different mini sites. These are the AR tables i am using
HZ_Cust_Accounts
HZ_Parties
Regards,The following query should give you resullts for B2C. Change the query based on your requirement incase if you want it for B2B. Please note that I haven't added alll the conditions. This should be your starting point.
Hope this helps,
RK
SELECT imt.msite_name,
hp.party_name
FROM jtf_um_subscription_reg jusr,
jtf_um_subscription_resp jure,
fnd_responsibility fr,
ibe_msite_resps_b imrb,
ibe_msites_tl imt,
fnd_user fu,
hz_parties hp
WHERE jusr.subscription_id = jure.subscription_id
AND jure.responsibility_key = fr.responsibility_key
AND fr.responsibility_id = imrb.responsibility_id
AND imrb.msite_id = imt.msite_id
AND imt.language = USERENV('LANG')
AND fu.user_id =jusr.user_id
AND fu.person_party_id = hp.party_id -
Joining 3 tables with null values
Hi,
I have three tables that have varying data in. I want to write a query which will list all three in the result set, but when one of the tables doesn't have a row, write in No Value.
I will be intending on joining the tables with account numbers. What will be the syntax of a join with three tables where I am not sure which table will have null values?
Thanks...Something like
select nvl(a.id,'No Value'), nvl(b.id, 'No Value'), nvl(C.id, 'No Value')
from (select id from t1) a,
(select id from t2) b,
(select id from t3) c
where a.id = b.id(+)
and a.id = c.id(+)
Hi,
I have three tables that have varying data in. I want to write a query which will list all three in the result set, but when one of the tables doesn't have a row, write in No Value.
I will be intending on joining the tables with account numbers. What will be the syntax of a join with three tables where I am not sure which table will have null values?
Thanks... -
Joining Two Tables with Total Amount
Hi All,
I'm trying to join to tables P02 and P30 on the invoice no fields but getting duplicates. In table P30 we need to sum the payment column per invoice to get the actual payment amount. This then needs to Join to table P02. I have uploaded sample
data on this link and provided an example on how the output should like.
https://app.box.com/s/pu8oa4f3jhrhm0ylshdz2fuo7541vn4z
Thanks
JagI figured out why the duplicates appear. I'm attaching another table supplier to fill in the missing propcode when running the query below
SELECT P02.P02_UNIQUE, p30.PROP_CODE, P02.SUPP_ALPHA+P02.SUPP_NUMERIC As SupplierCode, P02.INV_ALPHA+P02.INV_NUMERIC AS InvoiceNo,TotalPayment, Year, Month
FROM P02
CROSS APPLY (
SELECT PROP_CODE, SUM(TOTAL_AMOUNT) AS TotalPayment, P30.INVOICE_NUMB, DATEPART(year,[CREATED_DATE_SQL]) AS [Year], DATEName(Month,[CREATED_DATE_SQL]) AS [Month]
FROM dbo.P30
WHERE P02.INV_ALPHA+P02.INV_NUMERIC = P30.INVOICE_NUMB
GROUP BY PROP_CODE, COST_CENTRE, DATEPART(year,[CREATED_DATE_SQL]), DATEName(Month,[CREATED_DATE_SQL]), P30.INVOICE_NUMB
)P30
Where P02.SUPP_ALPHA+P02.SUPP_NUMERIC = '668'
Result below and the last row the prop_code is missing
I have another table supplier which has the suppliercode and propcode so was trying to use the prop_code field from supplier table instead of P30 table to fill in the gap. But when i do that i get duplicates and wrong values.
I have updated the sample data with supplier table. -
How to join 2 tables with unequal rows without resulting in a cartesian join
Hello,
This is the first time I have ever posted in any forum so please tell me if I should be doing this better.
Basically I have 2 tables with an unequal number of rows. For demonstration purposes, assume these are my 2 tables:
Table 1:
BaseKey
Letters
A
A
A
B
A
C
B
A
B
B
Table 2:
BaseKey
Numbers
A
1
A
2
B
1
B
2
B
3
I need to join them so that the data would appear like this
BaseKey
Letters
Numbers
A
A
1
A
B
2
A
C
null
B
A
1
B
B
2
B
null
3
Does anyone have any ideas how to do this using T-SQL without creating a cartesian join of 12 rows?
Thanks.>> This is the first time I have ever posted in any forum so please tell me if I should be doing this better. <<
Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. What you did post is useless! Can you program from it? Neither can we. And we have to do all the extra typing for you.
CREATE TABLE Foo
(base_something CHAR(1) NOT NULL,
something_letter CHAR(1) NOT NULL,
PRIMARY KEY (base_something, something_letter));
INSERT INTO Foo
VALUES ('A', 'A'),
('A', 'B'),
('A', 'C'),
('B', 'A'),
('B', 'B');
CREATE TABLE Bar
(CHAR(1) NOT NULL,
something_digit CHAR(1) NOT NULL,
PRIMARY KEY (base_something, something_digit));
INSERT INTO Foo
VALUES ('A', '1'),
('A', '2'),
('B', '1'),
('B', '2'),
('B', '3');
>> I need to join them so that the data would appear like this
base_something Letters Numbers <<
This looks like you are taking two decks of punch cards and merging them together, without any logical rules, just physical position in their decks relative to the base_something groups.
WITH Foo_Deck
AS
(SELECT base_something, something_letter,
ROW_NUMBER()
OVER (PARTITION BY base_something
ORDER BY something_letter) AS card),
Bar_Deck
AS
(SELECT base_something, something_digit,
ROW_NUMBER()
OVER (PARTITION BY base_something
ORDER BY something_digit) AS card),
SELECT F.base_something, F.something_digit, B.something_letter
FROM Foo_Deck AS F
LEFT OUTER JOIN
Bar_Deck AS B
ON B.base_something = F.base_something
AND B.card = F.card;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Join EQUI table with other table so as get address detail.
Hi All,
Can any one help me in the following case :
I have to pass Equipment No. EQUNR on the selection screen and get Address detail (city, region, state, country, zipcode )
now I am getting all this address related field in KNA1 table. Also I am able to join this two table with
KNA1-KUNNR join EQUI-KUNDE as common field.
Turning point
when I am passing test data of Equipment No. EQUNR 60099204 I am not getting the address detail,
because after passing EQUNR I am not getting KUNNR.
So can any one please help me in joining EQUI table to some other table with field name so that I can get the address detail.
ThanksHi,
The join between the table EQUI-kunde join KNA1-kunnr is ok but it not working for every value.
Example :-
In EQUI table when we pass Equnr - 60099204 we need to get some value in KUNDE field, then only it will join to KNA1 table. But this is not happening, I am not getting value for KUNDE, hence join is not performing.
So I need some other solution so that when we pass EQunr we can get the address details
one thing more equnr 60099204 is having address detail, if we'll check IE03 (transaction by clicking address envelop)
Thx. -
Join 2 tables with a reference table
I have two large tables that I am trying to join together by two columns. Below are the tables with two samples in each table, the reference table and also the final result that i want. Can anyone help me and any pointers. Thank you so much.
Join on xAlias = mAlias
Join on xValue =mValue
And if xValue =mValue is null then look at xRefValue = mRefValue
ResultPlease provide example data in tables. For an example of this, see the top of the code.
Try this:
DECLARE @1stTable TABLE (xitem VARCHAR(15), xAlias VARCHAR(30), xvalue VARCHAR(30))
INSERT INTO @1stTable (xitem, xAlias, xvalue)
VALUES
('HGJ53456FCN','Finish/Coating', 'Black Oxide'),('HGJ53456FCN','Series/List', '8301'),('HGJ53456FCN','Material', 'High Speed Steel-E'),('HGJ53456FCN','Number of Flutes', '3'),('HGJ53456FCN','Overall Length (Inch)', '3-19/32'),
('HGJ53456FCN','Threads Per Inch', '12'),('HGJ53456FCN','Thread Limit', 'H3'),('HGJ53456FCN','Shank Diameter (Inch)', '0.429'),('HGJ53456FCN','Thread Size (Inch)', '9/16-12'),('HGJ53456FCN','Chamfer', 'Plug'),
('HGJ53456FCN','Thread Direction', 'Right Hand'),('HGJ53456FCN','Thread Length (Inch)', '63/64'),('HGJ53456FCN','Thread Standard', 'UNC'),('LOP65986','Finish/Coating', 'Black Oxide'),('LOP65986','Series/List', '5303S'),
('LOP65986','Material', 'High Vanadium High Speed Steel'),('LOP65986','Number of Flutes', '4'),('LOP65986','Overall Length (Inch)', '38078'),('LOP65986','Threads Per Inch', '10'),('LOP65986','Thread Limit', 'H3'),
('LOP65986','Shank Diameter (Inch)', '0.59'),('LOP65986','Thread Size (Inch)', '3/4-10'),('LOP65986','Chamfer', 'Bottoming'),('LOP65986','Thread Direction', 'RIGHT Hand'),('LOP65986','Thread Length (Inch)', '2'),
('LOP65986','Thread Standard', 'UNC')
DECLARE @2ndTable TABLE (mItem int, mAlias varchar(30), mValue varchar(50))
INSERT INTO @2ndTable (mItem, mAlias, mValue)
VALUES
(53456, 'Manufacturer''s Part Number', NULL),(53456, 'Chamfer', 'Plug'),(53456, 'Finish/Coating', 'Oxide'),(53456, 'Material', 'Vanadium High Speed Steel'),(53456, 'Material Application', 'Carbon Steel; Hardened Steel; Stainless Steel'),
(53456, 'Number of Flutes', '3'),(53456, 'Overall Length (Inch)', '3-19/32'),(53456, 'Oversize (Yes/No)', 'No'),(53456, 'Series/List3', '00'),(53456, 'Shank Diameter (Decimal Inch)', '0.4290'),
(53456, 'Square Size (Decimal Inch)', '0.3220'),(53456, 'Thread Direction', 'RIGHT Hand'),(53456, 'Thread Length (Inch)', '1-21/32'),(53456, 'Thread Limit', 'H3'),(53456, 'Thread Size (Inch)', '9/16-12'),
(53456, 'Thread Standard', 'UNC'),(53456, 'Through Coolant (Yes/No)', 'No'),(65986, 'Manufacturer''s Part Number', NULL),(65986, 'Chamfer', '2-1/2'),(65986, 'Finish/Coating', 'Oxide'),
(65986, 'Material', 'High Speed Steel'),(65986, 'Material Application', 'Cast Iron; Ductile Iron; Steel'),(65986, 'Number of Flutes', '4'),(65986, 'Overall Length (Decimal Inch)', '4.2500'),(65986, 'Overall Length (Inch)', '4-1/4'),
(65986, 'Oversize (Yes/No)', 'No'),(65986, 'Shank Diameter (Decimal Inch)', '0.5900'),(65986, 'Thread Direction', 'RIGHT Hand'),(65986, 'Thread Length (Decimal Inch)', '2.0000'),(65986, 'Thread Length (Inch)', '2'),
(65986, 'Thread Limit', 'H3'),(65986, 'Thread Size (Inch)', '3/4-10'),(65986, 'Thread Standard', 'UNC'),(65986, 'Through Coolant (Yes/No)', 'No')
DECLARE @refTable TABLE (aliasName VARCHAR(30), xRefValue VARCHAR(40), mRefValue VARCHAR(50))
INSERT INTO @refTable (aliasName, xRefValue, mRefValue)
VALUES
('Finish/Coating','Black Oxide','Oxide'),('Finish/Coating','SH47 Oxide Nitride','Oxide'),('Finish/Coating','Steam Oxide','Oxide'),('Material','High Speed Steel-E','Vanadium High Speed Steel'),('Material','High Vanadium High Speed Steel','Vanadium High Speed Steel'),
('Material','High Vanadium High Speed Steel-E','Vanadium High Speed Steel'),('Material','High Vanadium High Speed Steel-E-PM','Vanadium High Speed Steel'),('Material','High Speed Steel','Vanadium High Speed Steel'),('Material','Carbide','Solid Carbide'),('Material','Powdered Metal Cobalt','Powdered Metal'),
('Material','High Vanadium High Speed Steel','High Speed Steel'),('Material','High Carbon Steel','High Speed Steel'),('Material','High Speed Steel-E','High Speed Steel'),('Material','High Vanadium High Speed Steel-E','High Speed Steel'),('Material','High Speed Steel','High Carbon Steel'),
('Material','High Speed Steel-E-PMT15 Cobalt','Cobalt Vanadium High Speed Steel'),('Material','High Speed Steel Cobalt','Cobalt'),('Material','High Speed Steel-E Cobalt','Cobalt'),('Material','High Speed Steel-E-PMT15 Cobalt','Cobalt'),('Material','High Carbon Steel','Carbon Steel'),
('Material','Bottoming','2-1/2'),('Material','Taper','2-1/2'),('Material','Bottoming','1 to 3-1/2'),('Material','Taper','1 to 3-1/2')
SELECT xItem, mItem, xAlias, xValue, mValue
FROM @1stTable st
INNER JOIN @2ndTable nd
ON st.xAlias = mAlias
AND st.xValue = mValue
LEFT OUTER JOIN @refTable rt
ON st.xAlias = rt.aliasName
AND st.xvalue = rt.mrefValue
ORDER BY xItem, xAlias -
Joining two tables with different DB
Hi
We have 2 sources DB2 and Oracle.
In DB2 we have two tables which stores.
Tbl1
Case_no Information1 Information2 Information3
11112 sddf asd null null
11113 asd asd null null
Tbl2
Inf Info1 Code Info3
Xedy Asdf 111 afder
Mad Tag 123 top
The above tables are complex join with this condition
Tbl1.case_no=Tbl1.case_no.
Oracle tbl
Code Code_desc
111 Very good
123 bad
My requirement is to join the tbl2 with Oracle tbl. Based on the codes in DB2 table I should display the Code_desc in my reports. Like this
Case_no Code Code_desc
11112 111 Very good
11113 123 bad
But I am getting the Cartesian result.
Case_no Code Code_desc
11112 111 Very good
11112 123 bad
11113 111 Very good
11113 123 bad
Please help to resolve.
Regards
MDSelect Oracletbl and tbl2, right click on them open physical diagram, selected objects. In the physical diagram page Create a join between Oracletbl and tbl2 with the condition code=code.
In business model create a complex join between these two. Now reload metadata/restart services check output.
Let me know if this does not work you. -
Joining 3 tables with similar structure
Hello all,
I'm executing sql queries in oracle 10g.
I want to join 3 tables into a single new table containing all the records from the 3 individual tables. The balance should be Summed up whereever the reg_id is duplicated between the 3 tables, such that there is just one entry per reg_id with the summed balance in my new table.
Sample data ( similar tables, with different values ) . tables : temp1, temp2, temp3
reg_id | balance
92603013 183.77
92611902 419.46
92766121 77.04
93527720 24.84
93581368 120.09
93684684 89.88
92611902 113.66
93898873 52.19
93911192 53.93
93939027 89.88
93684684 152.58
Appreciate if someone can help me with the syntax.
thanks in advanceHi,
Maybe this is what you want:
CREATE TABLE temp123 AS
WITH union_of_all_3 AS
SELECT reg_id
, balance
FROM temp1
UNION ALL
SELECT reg_id
, balance
FROM temp2
UNION ALL
SELECT reg_id
, balance
FROM temp3
SELECT reg_id
, SUM (balance) AS balance
FROM union_of_all_3
GROUP BY reg_id
;If that's not it, then post INSERT statments for each of the 3 original tables, and the contents of the new table after it is populated. -
Can we join 3 tables with left outer join
hi friends.
Can any one tell how to join 3 tables using <b>left outer join</b>...i tried by taking some fields of <b>ekko,ekpo,eket</b>, but this not working ... plz give a sample code with some fields.Hi Uday
<b>Inner joins using 3 tables </b>
<i><b>Try this :-</b></i>
SELECT stpo~stlnr stpo~idnrk mast~matnr mara~mtart stpo~menge
INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast
JOIN stpo ON stpo~stlnr = mast~stlnr
JOIN mara ON mara~matnr = mast~matnr
WHERE stpo~stlty = 'M' "AND stpo~idnrk IN s_matnr
AND mast~werks = 1000.
<b><i>Here s_matnr is a select-options on the selection-screen. </i></b>
<i><b>Or this. </b></i>
<b>Code: </b>
Select single Vbrk~Bukrs Vbrk~Kunrg Vbrk~Vbeln
Vbrk~Fkdat Vbrk~Bstnk_Vf Vbrk~Zterm
Tvzbt~Vtext
Vbak~Vbeln Vbak~Bstdk
Likp~Vbeln Likp~lfdat Likp~Lfuhr
into w_vbrk
from vbrk
inner join Tvzbt on Tvzbt~Zterm = Vbrk~Zterm and
Tvzbt~Spras = sy-langu
Inner join Vbfa as SalesLnk
on SalesLnk~vbeln = pu_vbeln and
SalesLnk~vbtyp_v = c_order
inner join Vbak on Vbak~Vbeln = SalesLnk~Vbelv
Inner join Vbfa as DeliveryLnk
on DeliveryLnk~vbeln = pu_vbeln and
DeliveryLnk~vbtyp_v = c_Delivery
inner join Likp on Likp~Vbeln = DeliveryLnk~Vbelv
where vbrk~vbeln = pu_Vbeln.
<i><b>This code locates sales, delivery and payment terms info from a billing document number.</b></i>
<i><b>or</b></i>
<b>
Here, this one also works fine :</b>
select zfpcd~cadivi zfpcd~proforma zfpcd~factura zfpcd~aniofactura
zfpcd~montousd zfpcd~montoap zfpcd~ebeln zfpcd~inco1
zfpcd~lifnr lfa1~name1 zcdvs~status zfpcd~conint
into it_lista
from zfpcd inner join zcdvs
on zfpcd~ebeln = zcdvs~ebeln
and zfpcd~proforma = zcdvs~proforma
and zfpcd~lifnr = zcdvs~lifnr
inner join lfa1
on zfpcd~lifnr = lfa1~lifnr
where zcdvs~status = '04'.
Reward if helpfull
Regards
Pavan -
Want to Join two tables with cursors
Can anyone tell me how to join two tables only by cursors.
Not with:
1.Joining condition
2.Procedure etc.
Only cursors with passing parameters.
SowmyaThis is my assignment. I want to get the matching records from both tables. I have pk, fk for both tables for deptno.Can I pass parameter for this.
dept table:
deptno deptname
10 sales
20 Erp
30 hr
40 marketing
emp table:
Empno deptno Name
1 10 lee
2 20 hans
3 10 peter
4 30 james
5 30 king
Output should be:
deptno empname empno deptname
10 lee 1 sales
10 peter 3 erp
30 james 4 hr
30 king 5 marketing
Maybe you are looking for
-
Creating a Arabic PDF using SQR program
Arabic display Hi All I am trying to create a PDF report via Peoplesoft SQR using SQRW command. I get the expected result if I choose LIS or HTML as my output. But in case of PDF, I am missing the Arabic words in my report. Version of Adobe - 8. OS
-
Hi, My client needs mannual number range for booking all documents. Now I want to reset a vendor payment clearing document(i.e. vendor amt is net of w.holding taxes) as system does not allow to reset net of tax based cleared document. Pls. help. Rega
-
{Today} variable in content search web part
Hello, I am having issues with the {today} variable in the SharePoint 2013 Content Search Web Part. I'm trying to get all list items that have a Start date greater or equal to Today. I created a Search Managed Property called "NewsPublishingStartDate
-
CCMS Operating System Alert Monitor for Filesystem
Hi, In alert monitor set for operating system, for some filesystems the freespace & percentage_used were showing zero and saying value is obsolete. But those filesystem were existing with some space used in it. How to make that particular filesystem
-
In CPanel, I have three Adobe icons (Adobe AIR- version 3.1.0, Acrobat Reader - v. 10.1.7, and Flash Player, v 11.9.900) In many instances, an emailed pdf download will not open and giving an error msg that Adobe's already running. I would assume I'