Join the data
Hi everybody,
I have a question about join the data from to difference table.
Table A : Table B :
Acount | Disbursed_Date Acount | Disbursed_Date
01A2 31-Jan-2010 01A2 31-Jan-2011
01A2 28-Jan-2010 01A2 29-Feb-2011
01A2 31-Mar-2010 01A2 31-Mar-2011
I want it to show the output as below :
Result :
Acount | Disbursed_Date
01A2 31-Jan-2010
01A2 28-Jan-2010
01A2 31-Mar-2010
01A2 31-Jan-2011
01A2 29-Feb-2011
01A2 31-Mar-2011
can you show me the sql how to join those Table A and Table B, and show the output as above?
Big Thank.
Dorang
select * from tablea
union all
select * from tableb
order by account, disbursed_date;
Similar Messages
-
Joining the data from two Tables
I create a table with six months date from Jan to Jun. Another table with July trough Sept.
Now I want one table in which I am going to at the end of the year have all 2007 fiscal data.
I do not want to restore them ever back to the components. How do I do this?If I understand you correctly, I think you merely want to enlarge the first table enough to accommodate the data from the second table. Then select the cells in the second table and copy and paste them into the newly created space in the first table. Ask if you need more detail instructions on how to do this.
-
Need to join the data, of different tables
I have some data in 3 tables, Table 1 has all the names say, table1 has column Name with data as A,B,C,D,E. Table 2 has columns Name,Logins_T2,Entering_T2. Same way table2 has columns Name,Logins_T3,entering_T3. Now, I want to join these 3 tables, i want
all the names of table1 and the columns logins_T2,entering_T2,logins_T3,entering_T3.
How can I join them, i tried by using left join but it is not giving the correct result, can anyone help me do thisI think this is what you are trying to do. Please try this.CREATE TABLE Test1 (Name varchar(20), Col2 varchar(20))
CREATE TABLE Test2 (logins_T2 varchar(20), entering_T2 varchar(20))
CREATE TABLE Test3 (logins_T3 varchar(20), entering_T3 varchar(20))
INSERT INTO Test1(Name, Col2) VALUES('A', 'test1_A'), ('B', 'test1_B'), ('C', 'test1_C'), ('D', 'test1_D')
INSERT INTO Test2(logins_T2, entering_T2) VALUES('A', 'test2_A'), ('C', 'test2_C')
INSERT INTO Test3(logins_T3, entering_T3) VALUES('B', 'test3_B'), ('C', 'test3_C')
SELECT * FROM Test1 t1
LEFT OUTER JOIN Test2 t2 ON t1.Name = t2.logins_T2
LEFT OUTER JOIN Test3 t3 ON t1.Name = t3.logins_T3
Prakash Machiraju
Please vote if you find this posting was helpful or Mark it as answered.
I am doing this way,
SELECT t1.name,t2.logins_T2,enteringS_T2,t3.Logins_T3,t3.entering_T3 FROM Test1 t1
LEFT OUTER JOIN Test2 t2 ON t1.Name = t2.Name
LEFT OUTER JOIN Test3 t3 ON t1.Name = t3.Name
Logins and enterings are the integers and Table 2 and 3 also has column 'Name'. -
Unable to retrive the data using self join
I am trying to find the time taken to close a ticket. The ticket goes through various stages: NEW, INPROCESS, CLOSED, REOPENED. If the ticket is reopened then the next stage would be INPROCESS and then CLOSED.
The CC_TICKET_INFO table contains information about the last stage of the ticket. CC_TICKET_HISTORY table contains information about all the stages of the ticket.
The challenge here is if the ticket is reopened then it should be counted as 2 instances instead of 1.
First instance from stages: NEW --> INPROCESS --> CLOSE
Second instance from stages: REOPEND --> INPROCESS --> CLOSE.
Follwoing SQL is to generate the data:
CREATE TABLE CC_TICKET_INFO
TICKET_ID VARCHAR2(20 BYTE) NOT NULL
, TICKET_STATUS VARCHAR2(60 BYTE)
, created_date timestamp(6)
, LAST_CHANGED timestamp(6)
, ASSIGNED_TO VARCHAR2(20)
, CONSTRAINT PK_CC_TICKET_INFO PRIMARY KEY
ticket_id
CREATE TABLE CC_TICKET_HISTORY
TICKET_ID VARCHAR2(20 BYTE) NOT NULL
, TICKET_STATUS VARCHAR2(60 BYTE)
, CREATED_DATE TIMESTAMP(6) NOT NULL
, ASSIGNED_TO VARCHAR2(255 BYTE)
, CREATED_BY VARCHAR2(60 BYTE)
, CONSTRAINT PK_CC_TICKET_HISTORY PRIMARY KEY
TICKET_ID
, CREATED_DATE
insert into cc_ticket_history values ('D21207155', 'NEW', '6/28/2013 17:28:59', null, 'jsg-st');
insert into cc_ticket_history values ('D21207155', 'INPROCESS', '6/28/2013 17:48:19', 'ah-eg', 'ah-eg');
insert into cc_ticket_history values ('D21207155', 'CLOSED', '6/28/2013 18:54:23', 'ah-eg', 'ah-eg');
insert into cc_ticket_history values ('D21207155', 'REOPENED', '7/2/2013 19:55:04', 'ah-eg', 'jsg-st');
insert into cc_ticket_history values ('D21207155', 'INPROCESS', '7/2/2013 20:11:17', 'sr-eg', 'sr-eg');
insert into cc_ticket_history values ('D21207155', 'CLOSED', '7/2/2013 23:06:16', 'sr-eg', 'sr-eg');
insert into CC_TICKET_INFO values ('D21207155', 'CLOSED', '6/28/2013 17:28:59', '7/2/2013 23:06:16', 'sr-eg');
I want to find the time difference betwen '6/28/2013 18:54:23' and '6/28/2013 17:28:59' (First instance)
and between '7/2/2013 23:06:16' and '7/2/2013 19:55:04' (Second instance)
The closest I am getting is the through this query:
select L.ticket_id, L.CREATED_DATE, R.CREATED_DATE as close_date, L.TICKET_STATUS, R.TICKET_STATUS from cc_ticket_history L RIGHT join cc_ticket_history R on (L.rowid < R.rowid) where (L.TICKET_STATUS = 'NEW' AND R.TICKET_STATUS ='CLOSED') OR (L.TICKET_STATUS = 'REOPENED' AND R.TICKET_STATUS ='CLOSED');
Can it be done through SQL?select ticket_id,ticket_status,created_date,
case when ticket_status = 'CLOSED'
and lead(ticket_status) over (partition by ticket_id order by created_date) = 'REOPENED'
then lead(created_date) over (partition by ticket_id order by created_date) - created_date
when ticket_status = 'REOPENED'
and lag(ticket_status) over (partition by ticket_id order by created_date) = 'CLOSED'
then created_date - lag(created_date) over (partition by ticket_id order by created_date)
end time_difference
from cc_ticket_history
where ticket_status in ('CLOSED','REOPENED')
TICKET_ID
TICKET_STATUS
CREATED_DATE
TIME_DIFFERENCE
D21207155
CLOSED
28-JUN-13 06.54.23.000000 PM
+000000004 01:00:41.000000
D21207155
REOPENED
02-JUL-13 07.55.04.000000 PM
+000000004 01:00:41.000000
D21207155
CLOSED
02-JUL-13 11.06.16.000000 PM
Regards
Etbin -
Need to change the date of joining of employee
Hi All,
I have gone through some threads similar to this subject an also tried to do changes from PA41 but i am facing some problems during the procedure.
We have transferred some employees to sap system with their original date of joining and payroll was run from some other date for those employees. So i need to change the date of joining of those employees.
For example : Below is the line items of one employee from table infotype 0.
End date Start date Changed on
22.02.2009 19.02.2007 19.02.2009
31.03.2009 23.02.2009 19.02.2009
31.12.2009 01.04.2009 14.10.2009
31.12.9999 01.01.2010 21.01.2010
Payroll was run from Feb-09 onwards and i want put date of joining for this employee as 23.02.2009.
I want to know which date i need to change??...When i am trying to change the first start date i.e. 19.02.2007 to my desired start date, but it is not allowing me to do that as end date is smaller.
Please tell me how would i change the joining date of employee as 23.02.2009 ?.
Thanks.Try this
22.02.2009 19.02.2007
31.03.2009 23.02.2009
31.12.2009 01.04.2009
31.12.9999 01.01.2010 take this record form PA30 IT0000 Over View (Shif + F8) Copy that record and change the Start date
as 2302.2010 so another record will be created
22.02.2010 01.01.2010
31.12.9999 23.02.2010
Just try and let me know -
How can i join the header and item table to fetch the data
hi experts,
i have a doubt in using inner join or for all entries, for fetching the data from the item table mseg, by taking the doc.no from mkpf. Plz sort out the difference, what happens, if i use the both statements for fetching dataHi,
Both has same functionality.
but if u are using FAE, u ahev to check for the
~intial condition of the source table,
~ duplicate entries, if any
Inner join will fetch the data from all the join tables at once. FAE will fetch the date from a table first then use that data to fetch data from subsequent table.
say in ur case, if u r using FAE,
1.select from mkpf.
2.select from mseg fae in I_MKPF.
first try using JOIN. if it is taking lots of time, then try FAE.
regards,
madhu -
Inner join in ABAP and exporting the data
Hi,
I want to use inner join in ABAP for retrieving data from 2 tables and export that data.How will i do it?Hi,
Refer following code
*--Select query to pick the data from table VBRK
VBRP and VBPA using inner join
SELECT a~vbeln "Billing document
a~fkdat "Billing date
a~fktyp "Billing category
a~fkart "Billing type
a~vtweg "Distribution channel
a~knumv "Number of doc condition
b~posnr "Billing item
b~matnr "Material Number
b~werks "Plant
b~vgbel "Referance
b~netwr "Net value of billing item
b~wavwr "Cost in document currency
c~kunnr "Partner function
FROM vbrk AS a
INNER JOIN vbrp AS b
ON avbeln EQ bvbeln
INNER JOIN vbpa AS c
ON bvbeln EQ cvbeln
AND bposnr EQ cposnr
INTO CORRESPONDING FIELDS OF TABLE it_vbrp
WHERE fkdat IN s_erdat
AND parvw EQ 'ZS'.
IF sy-subrc EQ 0.
*--Sort table by
SORT it_vbrp BY vgbel1.
ENDIF.
Regards,
Prashant -
Crosstab two joined tables multiplies the data in each column ....
below is code that crosstabs monthy sales numbers and totals for each month. So what I need to do is add a column that totals last years sales (table will be called [2013]) and add a column called 2013 YTD. I also need to add a calculation column that
calculates growth from one year to another. So I join the 2013 table and add one last line that sums 2013 sales but i need only Jan-Mar at this point. in other words I just need to see the total sales for each dealer from 2013 Jan-Mar while still viewing Jan-Dec
for the current year. So looking at the end product I need to see the Dealer Info, Jan, Feb, Mar, Apr......and at the end 2013 Sales and Growth. Thus, the Where clause. Unfortunately, each months sales are multiplied x 3 with or without the 2013 sum line.
As soon as I join the tables the numbers get multiplied.
What am I missing??????
SELECT
substring([2014].Dealer,18,50)AS
[Dealer Name],substring([2014].Dealer,9,1)AS
[District],substring([2014].Dealer,11,6)AS
[Dealer Code],
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 1 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Jan,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 2 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Feb,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 3 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Mar,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 4 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Apr,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 5 THEN
[2014].[Sales Count]
ELSE 0 END)
AS May,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 6 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Jun,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 7 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Jul,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 8 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Aug,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 9 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Sep,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 10 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Oct,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 11 THEN
[2014].[Sales Count]
ELSE 0 END)
AS Nov,
SUM(CASE
WHEN [2014].[Transaction Sales Month]
= 12 THEN
[2014].[Sales Count]
ELSE 0 END
AS
Dec,
SUM([2014].[Sales Count])
AS [2014 Total],
FROM
dbo.[2014]
GROUP
BY substring([2014].Dealer,18,50),substring([2014].Dealer,9,1),substring([2014].Dealer,11,6)This needs to be moved to Transact-SQL forum. You may want to post DDL of your tables, some input data (as insert statements) and desired output.
In the meantime I think you'll find this blog post helpful:
Aggregates with multiple tables
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
hello all,
can anyone help me write an outer join b/n the two tables below. The joining condition has if's and or's.
table 1 has 2 million rows, table 2 is very small
TABLE1
CUSTOMER_ID
CITY
STATE
1
SKOKIE
IL
2
CHICAGO
IL
3
CARY
NC
ERIE
PA
PHILLY
PA
CHARLOTE
NC
2 MILLION
CITYXY
STATEX
TABLE2
CITY
STATE
CONTACT
IL
OJO
ERIE
BRITT
PA
MIKE
PITTSBURG
PA
HILTON
N043
TAT
affi
B
affi
R
b0b
Q
b0b
CHARLOTE
NC
b0b
problem :: for all the data in table1, I need to find out the CONTACT from table 2 And the join condition would be as below
1. either both TABLE1.CITY=TABLE2.CITY AND TABLE1.STATE=TABLE2.STATE and get CONTACT
OR
2. TABLE1.CITY=TABLE2.CITY AND TABLE2.STATE IS NULL and get the value of CONTACT
OR
3. TABLE1.STATE=TABLE2.STATE AND TABLE2.CITY is null and get the value of CONTACT
I need a query like this
SELECT A.CUSTOMER_ID, A.CITY, A.STATE, B.CONTACT
FROM TABLE1 A, TABLE2 B
WHERE (join condition fitting in the 3 condition mentioned above)Dear OP,
Do you want something like this?
> with t1 as
-- Start of SAMPLE DATA
(select 1 CUSTOMER_ID, 'SKOKIE' CITY, 'IL' STATE from dual union
select 2, 'CHICAGO', 'IL' from dual union
select 3, 'CARY', 'NC' from dual union
select 4, 'ERIE', 'PA' from dual union
select 5, 'PHILLY', 'PA' from dual union
select 6, 'CHARLOTE', 'NC' from dual)
t2 as
(select null CITY, 'IL' STATE, 'OJO' CONTACT from dual union
select 'ERIE', null, 'BRITT' from dual union
select null, 'PA', 'MIKE' from dual union
select 'PITTSBURG', 'PA', 'HILTON' from dual union
select 'N043', 'TAT', 'affi' from dual union
select null,'B', 'affi' from dual union
select null,'R', 'b0b' from dual union
select null,'Q', 'b0b' from dual union
select 'CHARLOTE', 'NC', 'b0b' from dual
--- END IF SAMPLE Data
select * from t1 full outer join t2
on ( nvl(t1.city,t2.city) = nvl(t2.city,t1.city)
and nvl(t1.state,t2.state) = nvl(t2.state,t1.state) )
order by 1,2,3,4
CUSTOMER_ID CITY STATE CITY STATE CONTACT
1 SKOKIE IL IL OJO
2 CHICAGO IL IL OJO
3 CARY NC
4 ERIE PA ERIE BRITT
4 ERIE PA PA MIKE
5 PHILLY PA PA MIKE
6 CHARLOTE NC CHARLOTE NC b0b
N043 TAT affi
PITTSBURG PA HILTON
B affi
Q b0b
R b0b
12 rows selected
Elapsed: 00:00:00.112
Hope this is helpful. If not please let us know what is you desired result (sample) if your data was like above?
vr,
Sudhakar -
Why can I not join the wi fi in the hotel on my I.phone using iso7 ???? I have turned off data roaming any ideas?????
is it free or do you have to sign up and pay and is there a password
Havee you asked the hotel ??? -
Data in 0material and the 0material join infoset data is differ
Hi all,
I have two ODS's(Orders item and Billing item) and info object 0Material. and i have joined these two ODS's with 0Material by the field 0material. When i refresh a report developed in ODS it is giving correct values but when i refresh the report developed in infoset it is giving double the values.
Can anyone tell what might be the problem?.
Regards,
Muruganand.KHi Ram,
How do i confirm that when i execute the report on Infoset, it is fetching the data from all the ODS objects and from the Info Object. but ehen i execute on ODS, it is only fetching from that particular ODS. Any flow of data in infoset that i can get from the infoset joins to confirm this duplicate records are populated in Report...
Regards,
Muruganand.K -
My daughter locked herself out of her phone cannot remember the advanced password setting, we share an Itunes account and both recently joined the cloud, if she resets her phone all her information will be gone, will it affect the data on my phone as well
No, when resetting an iPhone it resets the actual data contained within the phone, nothing on your iCloud will be affected. It is a good idea to use seperate iClouda and iTunes accounts then you can each create your own backups regularly without your daughters backup overwriting yours or vice versa.
-
Define a join in Webi Report which gets the data from two Excel files
Hello,
I have the following excel records as a source for my Webi Report:
Excel 1
Excel 2
Date
Month
Month
Year
Year
Total Number of Days
in Month
No. Of Exec
Functional
Area
Now I need to show No. of executions/Total Number of Days in Month per functional area (Where Month of Excel 1 is Month of Excel 2).
For this:
I have Merged, Month of Excel 1 and Month of Excel 2, Year of Excel 1 and Year of Excel 2.
Created a variable vNoofExec , No. of Exec/Total Number of Days in Month.
Created a graph, with Merged Month, Merged Year, vNoofExec with Region Color on 'Functional Area'.
But, it doesn't work.
If I replace vNoofExec with No. Of Exec I get the data, but not with vNoofExec.
Any Idea how we can get a solution for this?
Best regards,
Praveen.Hi Amit,
Thank you for your reply.
I tried putting them in a table to see if I am getting the value for vNoofExec but, no, I am not getting. Here is the dummy data for both the excels:
1. Excel 1:
Year
Month
Week
Date
No. Of Exec
Functional Area
2013
1
30
26
1
FA1
2013
2
21
20
12
FA2
2013
3
21
21
1
FA3
2013
4
21
22
5
FA4
2013
5
21
23
2
FA5
2. Excel 2:
Year
Month
TotalDays
2013
1
31
2013
2
28
2013
3
31
2013
4
30
2013
5
31
What I found is, if I create a measure like, [No. of Exec] where ([Functional Area]="FA1") and use this measure in the graph I am able to see the data even if I use Total Days in the Graph, but, I cannot create multiple measures like this because for me number of Functional Areas will be changing always. -
Why do we get the data from a view to a report.
hi
why do we get the data from a view to a report. is it possible to get the data from a view in all the cases?hi Jyotssna,
Suppose you are planning to get the data from multiple tables then you got to specify seveal condtions and make use of joins which results in poor performance in fetching the data . In order to improve the performance we make use of views where the conditions of different tables are defined and the data is fetched accordingly.
Regards,
Santosh -
How do I figure where is the data in a materialized view coming from
Hi: when I run select NAME, OWNER from dba_mview_refresh_times, I see a number of materialized views. How do I find more details about this view i.e where is the data coming from and which fields. The source table that is in another database changed. But the view on my database where the materialized view exist has not changed. I want to confirm from where is data coming in this view
TIA
RaviSQL> select * from dict where table_name like 'ALL%MVIEW%'
TABLE_NAME COMMENTS
ALL_BASE_TABLE_MVIEWS All materialized views with log(s) in the database that the user can s
ee
ALL_MVIEWS All materialized views in the database
ALL_MVIEW_AGGREGATES Description of the materialized view aggregates accessible to the user
ALL_MVIEW_ANALYSIS Description of the materialized views accessible to the user
ALL_MVIEW_COMMENTS Comments on materialized views accessible to the user
ALL_MVIEW_DETAIL_PARTITION Freshness information of all PCT materialized views in the database
ALL_MVIEW_DETAIL_RELATIONS Description of the materialized view detail tables accessible to the u
ser
ALL_MVIEW_DETAIL_SUBPARTITION Freshness information of all PCT materialized views in the database
ALL_MVIEW_JOINS Description of a join between two columns in the
WHERE clause of a materialized view accessible to the user
ALL_MVIEW_KEYS Description of the columns that appear in the GROUP BY
list of a materialized view accessible to the user
ALL_MVIEW_LOGS All materialized view logs in the database that the user can see
ALL_MVIEW_REFRESH_TIMES Materialized views and their last refresh times for each master table
that the user can look at
ALL_REGISTERED_MVIEWS Remote materialized views of local tables that the user can see
13 rows selected.
Maybe you are looking for
-
Cisco ISE with TACACS+ and RADIUS both?
Hello, I am initiating wired authentication on an existing network using Cisco ISE. I have been studying the requirements for this. I know I have to turn on RADIUS on the Cisco switches on the network. The switches on the network are already programm
-
T420 Hinges second replacement in 1.5 years?
My T420 Hinges are beginning to wobble again and not adequately support the screen. Basically any minor bump to the computer moves the screen back and forth. This makes it very difficult to use the machine in a car, bus, airplane, or on any surface o
-
How to get Safari to save passwords?
I went on a website for the first time and Safari asked me if I wanted it to save my username and password, but I accidentally said "never for this site" even though I now want it to save them. Is there a way to change this? I'm using an iPad with iO
-
Hi all, Im in SRM 7.0.1. I need to create the delivery addresses and assign it to users in PPOMA_BBP. In SRM 5,the transaction for creating "Delivery address" was "EDIT INTERNAL ADDRESSES"(web) and BBPADDRINTC(SAPGUI). However in SRM 7,even with the
-
Accessing arrays in other classes
I want to access an array in another class. How do I do it. Class1 Method1() Fill OriginalArray[] Class2 Method2() If OriginalArray[0] = whatever //how can i access this array