Creation of View from Mutiple Tables (Union of result sets)
Hi,
I have started working on Information Steward very recently and Im working on creating some profiling rules in Data Insight.
I’m working on bringing data in two tables together to apply some common rules, I have tried view option but I’m not sure how to create the views as below without joins.
View should have common columns from Table1 and Table2 so I can perform below rules.
Check uniqueness of primary key column across both the tables. Like Id – Unique in view below
Combination of two different columns should be unique in both the tables. Like First name + Last Name Unique in view
I would like to create a view which is can be done using Aggregator in Information PC and Merger in BODS.
Permenent Employee
Id
First Name
Last Name
Age
salary
6
Sachin
Tendulkar
41
2000
7
Ajay
Jadeja
43
2000
9
Rahul
Dravid
40
2000
Contracting Employee
Id
First Name
Last Name
Age
salary
1
Sourav
Ganguly
41
2000
2
Ajith
Agarkar
38
2000
3
Anil
Kumble
43
2000
View
Id
First Name
Last Name
Age
salary
1
Sourav
Ganguly
41
2000
2
Ajith
Agarkar
38
2000
3
Anil
Kumble
43
2000
6
Sachin
Tendulkar
41
2000
7
Ajay
Jadeja
43
2000
9
Rahul
Dravid
40
2000
Please let me know you thoughts on how this can be achieved in SAP IS
This is not possible in IS. You'll have to create a view at db level. Or merge all data into one table, using DS as you say.
Similar Messages
-
How can i convert the data from mutiple-table to the other database(MSSQL)?
Dears,
How can i convert the data from mutiple-table to the other database such as MS-SQL?
I have a third party system based on MS-SQL 2000.
Now we want to make a integration between SAP R/3(Oracle) and SQL server.
When my user releases the purchase order in R/3, the application we coded will convert the releated data to the temp database on the SQL server.
But i don't know which tools will help me reach the purpose. BAPI, LSMW, IDoc... ???
Would anybody tell me which way is better and how to do?
Thanks a lot!
Kevin WangHello Kevin,
The question to use which method depend on your detail requirements. If you use BAPI, you need to find which Bapi can provide the data you want. Bapi normally use as a function called by external system. So you need to develop an external program like VB/Java to call this Bapi and move it to SQL. LSMW is use when you want to upload data from an external system to SAP. So it does not serve your requirement. Idoc can be use to export data to an external system. Again like Bapi, you need to find what Idoc can provide the data you want. However, it does not any programming from the external system. If I were you, based on your requirements, I think writing an Abap program that read the data you want and download it to NT/SQL server will be faster and easier. -
How to exclude the XML declaration from each row of the result set?
Hi,
I have a table with an XMLTYPE column and would like to SELECT a set of rows. How can I exclude the XML declaration from each row in the result set? My query currently looks like this, I'm executing it through Spring JDBC:
SELECT XMLSerialize(CONTENT t1.xmltext) FROM myschema.event t1 WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e") ORDER BY t1.time DESC
After selecting, in my application I convert each row into a String and concatenate all rows into one big string in order to parse it into a DOM model. I get a parser exception (org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed) because there are multiple XML declarations in my big string. Of course, I could manually check the String of each row whether it starts with the XML declaration, but it would be nicer if I could instruct the DB not to add it in the first place. Is there a way?
Thanks!
-- DanielaHi,
A couple of options I can think of :
SELECT XMLSerialize(CONTENT
XMLtransform(t1.xmltext,
xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/"><xsl:copy-of select="*"/></xsl:template>
</xsl:stylesheet>')
FROM myschema.event t1
WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e")
ORDER BY t1.time DESC
;or simply,
SELECT XMLSerialize(CONTENT
extract(t1.xmltext,'/')
FROM myschema.event t1
WHERE XMLEXISTS('$e/Event' PASSING XMLTEXT AS "e")
ORDER BY t1.time DESC
; -
Creation of view on single table?
Hi Team,
I have a requirement like for creaation of view on single table (QMEL) in SAP ECC side...
Note: in this table i need 2o fields only....not all fields.
First can we create view on single table?
if 'Yes' can any one tell , How we can creat view on single table?
While creation of view we have four options..
1)Data base view
2)Projection View
3)Maintanace view
4)Help view
in these four options which tyep of view we can choose for creation?
please can any one suggest me and do the need full..
i am waiting your responce...I quickly skimmed the links provided by others; and in my short discussions with DBA friend of mine; and other sources... partition should be based on user needs, sql server resources, and partition maintenance time.
Lets say you have 50 regions and 1) partition the data by region, AND 2) place each partition on a different disk, and 3) i am in Texas and only query data in the Texas region then performance will be increased because I am not scanning through the other
49 regions.
If you have temporal data (dependent on time - like say financial reports that are sent to the SEC) - the partitions are by time: 1) data from last 13 months is stored on SSD, 2) data 13 months - 3 years old is on HDD, and 3) data >3 years old is stored
on compressed HDD. (i say 13 months so you have an entire year and month to date) --- accountants can get the current data VERY quickly, project managers who need to see a 3 year trend will not have to wait long, and when the SEC calls, who cares?,
the reports can be queued and generated at night when no one is working.
I see partitions are giving the users the least amount of data to query which speeds their results. -
i have a table1 on the top, but i want to create a view from table 1 as view mentioned beneath the table 2. Could any of you please help me.
table1
ID
office
employee
activity
1
246
-9999
698
2
##-99
21480
698
3
104
-9999
7025
4
##-99
88908
7025
5
108
-9999
2415
6
##-99
17135
2415
7
246
-9999
698
8
##-99
21480
698
9
104
-9999
7025
10
##-99
88908
7025
11
108
-9999
2415
12
##-99
17135
2415
view
ID
office
ID1
employee
activity
1
246
2
21480
698
3
104
4
88908
7025
5
108
6
17135
2415
7
246
8
21480
698
9
104
10
88908
7025
11
108
12
17135
2415declare @forumsTable table (ID int, officeID int, employeeID INT, activityID int)
insert into @forumsTable (ID, officeID, employeeID, activityID)
values
(1 ,246, -9999, 698 ),
(2 ,-99, 21480, 698 ),
(3 ,104, -9999, 7025),
(4 ,-99, 88908, 7025),
(5 ,108, -9999, 2415),
(6 ,-99, 17135, 2415),
(7 ,246, -9999, 698 ),
(8 ,-99, 21480, 698 ),
(9 ,104, -9999, 7025),
(10 ,-99, 88908, 7025),
(11 ,108, -9999, 2415),
(12 ,-99, 17135, 2415)
select f1.ID, f1.officeID, f2.ID as ID1, f1.employeeID, f1.activityID
from @forumsTable f1
inner join @forumsTable f2
on f1.activityID = f2.activityID
and f1.officeID > 0
and f2.employeeID > 0
and f1.id - f2.id = -1
You really need to improve the relationship here.
Perhaps you could make office and activity an exclusive pair. -
Hi,
I would like to create a view from 4 different tables. How do I do it?.
Say for example, I need user_id from table A which has the trans_id in table B and C. and I need to get a admin_id from table D and show these related fields in one single row . I'm trying to create a view to achieve this.
Pls help.
Thanks,
AnanthAre you asking how to write the SQL, or just how to define the view (which I guess is pretty much the same thing)?
-
Materialized view from prebuilt table doesn't work with spatial types?
Hello, I'm trying to build a materialized view of a table using the prebuilt option and a pre-built table.
Oracle gives me an ORA-32304 error, saying it can't do this with user-defined types. The original table has no user-defined types, but does use an sdo_geometry column. Is this what it's complaining about?
Now I can sort of understand this, but here's my real problem: the materialized view I'm creating is comprised of a subset of the columns from the original table, but not the geometry column. Is Oracle right in refusing my prebuilt request? Does anyone know of a way around this (besides creating the MV from scratch without prebuilt).
I've successfully created an MV on another table, which doesn't have a spatial column, using the prebuilt option and a subset of columns.
(I'm using Oracle 11.2.0.2.0 on both master and slave databases)Good news, everyone! =)
SAPwebIDE team fixed this issue with MMD template in SAPwebIDE v1.10.2. available on http://hanatrial.ondemand.com.
This "Bug" or "Feature" was presented in 1.8.x and 1.9.x SAPwebIDE (i've used local installation) and now it's gone in v1.10.2. Thank you, SAPwebIDE Team! =)
The difference between versions of MMD template is only in one file (fixed one is on the right):
Master2.controller.js
And here it is:
Now, only one question remains: HOWTO:SAPUI5 Fiori-like report. (mix control's value as key into binding context)
Best regards, ilia. -
Creat View from Multiple tables , Multiple Select
Hello Everyone ,
I have a question and am not sure if this the correct forum to post it .
I have two table studentTable and CourseTable which is each student take more than one course . 1:M
for example Student1 take 2 courses (C1 , C2).
Student2 take 3 courses (C1,C2, C3).
I need to create a table/View that contain student information plus all the courses and the score for each course in one row.
for example
Row1= Student1_Id ,C1_code ,C1_name ,C1_Score ,C2_code,C2_name ,C2_Score
Row2=
Student2_Id,C1_code, C1_name,C1_Score,C2_code ,C2_name ,C2_Score , C3_code,C3_name,C3_Score
and since Student 1 just took two courses , I should enter NULL in 'Course 3 fields'
My Struggle is in the insert statement
I tried the following but it show an error
Insert Into Newtable
( St_ID, C1_code,c1_name, C1_Score ,C2_code ,C2_name,C2_score,C3_code ,C3_name,C3_score)
Select
(Select St_ID from StudentTable)
(Select C_code,c_name,c_Score
from Coursetable,SudentTable
where course.Stid =Studet.stid)
(Select C_code,c_name,c_Score
from course ,student
where course.Stid =Studet.stid ),
(Select C_code,c_name,c_Score
from course ,student
where course.Stid =Studet.stid );
I'm fully aware that the New table will break the rules of normalization ,but I need it in this way for specifc purpose.
I tried also the PIVOT BY functionality but no luck with it .
FYI , I'm not expert in using SQL Syntax , I just know the basic.
I will be great full for any helpfull suggestions to try ,
thank you very much.First Table is Member table which Represent
Students Information
.The fields in this table are
member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
widening_participation_level, nationality
Second Table is Modules table which include
the Courses' scores that Student took .
The fields in this table are
Module_result_k(Primary Key), member_sk(Foreign key to connect to Member table), member_stage_sk
,module_k(Foreign key to connect to Module table), module_confirmed_grade_src, credit_or_result
Third Table is
AllModuleInfo which is include
general information for each course .The fields in this table are
Module_k (Primary key), module_name ,module_code, Module_credit, Module stage.
The New table
that I will create has the following fields
member_sk (PrimaryKey), full_or_part_time, gender, age_at_entry, age_band_at_entry, disability, ethnicity,
widening_participation_level, nationality
" This will be retrieved from Member table"
Also will include
Module 1_name ,module1_code, Module1_credit, Module1_ stage, member1_stage_sk
, module1_confirmed_grade_src, credit1_or_result
Module 2_name ,module2_code, Module2_credit, Module2_ stage, member2_stage_sk
, module2_confirmed_grade_src, credit2_or_result
I will repeat this fields 14 times which is equal to Maximum courses number
that any of the students took.
//// I hope now my questions become more clear -
Authorization for all the maintenance views from one table
I have one table with data related to 5 systems.
I have created views with related data for each system.
These all are from one table only. while i am editing in one view, i must be able to edit the another view also. at a time 2 users cant edit the same view but at a time two users have to edit two different viws from same table.
I have to provide all authorization to all views at the same time.How to achieve this?.
Thanks.
Edited by: pagidala Ramesh on Oct 27, 2008 10:52 AMHi Pagidala,
This is my idea how much it can help you i am not sure but, create txcode for views and assign the authorizations for the txcodes according to your requirements. May be your issue will resolve.
Cheers!!
VEnk@ -
Need to create a vertical view from horizontal table w/delimited column
I would like to create a vertical view frm a table that has a colon delimited column.
I can get a single row to work. I need the level to reset to 1 when the row changes.
any Ideas? the key to the table is: sos,nr,prgm_cd,mth
here is my select for a single row w/where clause removed:
SELECT SOS,NR,PRGM_CD,trunc(sysdate-(30*LEVEL) , 'mm') MTH,
ADD_MONTHS(trunc(sysdate,'q'),-3*LEVEL) QTR,
SUBSTR(qty,
INSTR(qty,':',1,LEVEL) +1,
INSTR(qty,':',1,LEVEL+1) - INSTR(qty,':',1,LEVEL)-1) QTTY
FROM (SELECT SRC_SUPL_CD SOS,APPL_PRGM_DESIG_NR,TYP_PRGM_CD,':'||PAST_PRGM_QY||':' qty from
rssp_api_master )
CONNECT BY LEVEL < LENGTH(qty) - LENGTH(REPLACE(qty,':'))
ex. data
sos nr prgm_cd qty
aaa 3 xx 1:2:3:4:5:5
bbb 3 xx 9:10:11:12:13
need to look like this
aaa 3 xx 1
aaa 3 xx 2
bbb 3 xx 9
bbb 3 xx 10
bbb 3 xx 11See this thread
Re: rows into column
Nicolas. -
Hi Experts,
I want to create a view from 10 pricing tables rather than write 10 different select query in my application. Most of the columns of the pricing tables are same. I want all the data from these tables into the respective columns. Further I want an indicator as to which table does this record belong to. How can I achieve this?
Ex:
Table 1 columns: kappl kschl vkorg vtweg vkgrp
Table 2 columns: kappl kschl vkorg vtweg matkl matnr
if each table has two records, I want 4 records in my view in the respective columns along with the indicator that this record belongs to a specific column.
RegardsHi,
Placing 10 tables in one view will drastically affect performance. This is highly unrecommended.
Anyhow if you insist on doing so you can create [database view|http://help.sap.com/saphelp_nw04/helpdata/en/36/74c0358373003ee10000009b38f839/frameset.htm] or use explicitly joins in your program.
Keep in mind that althought it is possible to use projection (only selection of choosen column) it is not logically appropriate to locate which table this column belongs to (as far as we are talking about key fields) as both have the same field as key field.
On the other hand when using projection for non-key columns it is you who define what is to be selected and how, therefore you know which column belongs to which table.
i.e
data: begin of st,
lgart type t512w-lgart,
molga type t512w-molga,
lgtxt type t512t-lgtxt,
end of st.
select w~molga w~lgart t~lgtxt "<- here using aliases you know which column is taken from which table
into st
from T512W as W
inner join T512T as T on
W~LGART = T~LGART.
write: / st-lgart, st-molga, st-lgtxt.
endselect.
In this example lgart (key field) can be taken from either t512w or t512t, but fields mogla and lgtxt are taken from t512w and t512t respectively.
All in all this is correct as far as up to 3-4 tables are concerned. But 10 will be a disaster...
Hope this helps you
Marcin -
Select from different tables depending on results
how to do this in one select
4 tables
t3 and t4 are identical in structure but different data
select id from t1
If exists in select id from t2
then select data from t3
else
select data from t4
create table t1 (id number);
create table t2 (id number);
create table t3 (col1 varchar2(10), col2 varchar2(10));
create table t4 (col1 varchar2(10), col2 varchar2(10));
insert into t1 values(1);
insert into t1 values(2);
insert into t2 values(1);
insert into t3 values('DATA1','DATA2');
insert into t4 values('DATA3','DATA4');
commit;
Ive put values 1 and 2 into t1. as id=1 exists in t2, for that record I want the values from t3 but where id=2, I want the values from t4.
Possible in one select? Ive been playing with case statement but not getting anywhere near itHaving multiple table with same structure looks like a design flaw. What benefit that does bring. So please explain the reason to have 2 table with same structure.
Said that here are few more ways.
SQL> select id
2 , col1
3 , col2
4 from (
5 select t1.id
6 , decode(t2.id, null, 'T4', 'T3') table_handle
7 from t1
8 left
9 join t2
10 on t1.id = t2.id
11 ) a
12 join (
13 select 'T3' table_handle, col1, col2 from t3
14 union all
15 select 'T4' table_handle, col1, col2 from t4
16 ) b
17 on a.table_handle = b.table_handle;
ID COL1 COL2
1 DATA1 DATA2
2 DATA3 DATA4
SQL> select id
2 , col1
3 , col2
4 from (
5 select t1.id
6 , dbms_xmlgen.getxmltype('select col1, col2 from ' || decode(t2.id, null, 'T4', 'T3')) xml_data
7 from t1
8 left
9 join t2
10 on t1.id = t2.id
11 )
12 , xmltable
13 (
14 '/ROWSET/ROW' passing xml_data
15 columns col1 varchar2(10) path 'COL1',
16 col2 varchar2(10) path 'COL2'
17 );
ID COL1 COL2
1 DATA1 DATA2
2 DATA3 DATA4
SQL> -
Combining the same column from 2 tables with distinct result.
I have 2 tables with identical name columns. One is current people and the other is historical people. I want a select that returns any name that is in either table. I want each name listed only once. I want to see 1 entry for each name if it is in the current table, the historical table, or both tables. I can easily do a select distinct on each table but how do I join the queries to get 1 result set with no duplicates? The name column is not a key field and I don't want any other columns from either table.
Just a simple UNION:
select name
from current
union
select name
from historical; -
Tables listed in Result set field selction tab against Standard Data Objects in MDO configuration
On what basis are the tables gettting filled in the Result set field selction tab against Standard Data Objects in MDO configuration.
Only the handler class is specified before it gets filled.
Vivek.
Tags edited by: Michael ApplebyHi Vivek,
I would also recommend providing the version of the product either in the body of your discussion or in the tags (or both, preferred). If you are installing it on SMP 2.3 or some other platform, please add that as well. I have updated your tags and assigned the correct Category. Since there are so many different technologies in SAP for Mobile, tags and Categories help the helpers find your post and help you find a solution.
Thanks, Mike -
Crate view from multiple tables in mysql
does anybody know what the correct syntax is?
I need to do the following:
create view myView as select * from tOne, tTwo, tThree;this does not work in mysql. How this can be done?
thanksYou need to be using a version of MySQl that supports views, 5.0 or greater. This SQL will tell you which version you are using:
SELECT version();The tables also need to exist prior to the creation of the view.
Otherwise, that syntax should work...
http://dev.mysql.com/doc/refman/5.0/en/create-view.html
Maybe you are looking for
-
I just downloaded firefox about a week ago and the first day i used it i went on to tumblr, and i logged in just fine. But now a week later i'm trying to log into my tumblr and it says it's loading but then it goes straight back to the log in page. I
-
How do I connect my lucid to my computer?
I would like to connect my computer to my lucid phone. When I try it looks for a driver or other devices to connect. What do I need?
-
Macbook Pro Retina - Really struggling on storage options
Hi I converted over to Apple in 2011 with an iPad, a macbook Pro and an iPhone. As a long time PC user, it took me about 18 months to convert but, once there, I was fairly happy. I've always struggled with the iPhotos systems as I used to enjoy placi
-
Pause While Loop based on Iteration
I want to Pause a while loop based on a user imput and then continue if the input is changed. For example I want to have the loop run 5000 times then stop, later after it stops I change the number to 10,000, I want it to run only 5,000 more times. I
-
I've created a calendar but it won't let me press Buy Calendar
I've created a calendar but it won't let me press Buy Calendar