Combining of 2 different tables in to a query/view
Hi
I have 2 tables one is emp for employee details and another for courses for the courses which employee undergone.I want to create a view that contains the employees with each category went to the courses and rest of the employees didnt attended the courses in that group.The view or query should be combination of emp group wise by designation/groups who attended the courses and who didnt attended the courses.just an exmple of tables
Courses
emp emname job course
1 jon clerk msoffice
1 jon clerk office automation
2 rahul officer office automation
2 rahul officer spoken english
3 shyam officer spoken english
4 raj Manager office automation
Emp
empno ename job
1 jon clerk
5 ben clerk
2 rahul officer
3 shyam officer
6 rahim officer
4 raj manager
7 sandya manager
rgds
rateesh
Hi, Rateesh,
Sorry, I'm not sure I understand the problem. It would really help if you posted the results you want to get from the view.
Do you want to get all the information from the courses table, plus one row (from the emp table) for every employee who is not in the courses table?
The normal way to do that is an Outer Join.
For example, if you want to see all the departments (from the scott.emp table), and all of the employees in each department (from the scott.emp table), and you also want to see departments with no employees, you can say:
SELECT d.deptno
, e.ename
FROM scott.dept d
LEFT OUTER JOIN scott.emp e ON d.deptno = e.deptho;Since your tables are denormaliized (that is, the empname and job are repeated in different tables), you can also do that with a UNION, like you tried. You'll get all of the data from the courses table (for the employees who are in the courses table), and the data from the emp table, but only for the employees who are not in the courses table. You can put a literal NULL in the course column of SELECT clause, since these people will have no course.
Using the scott.dept and emp tables, here's how to simulate an outer join with a UNION.
SELECT deptno
, emp
FROM scott.emp
UNION
SELECT deptno
, NULL AS emp
FROM scott.dept d
WHERE NOT EXISTS ( -- Make sure this department is not in the emp table
SELECT NULL
FROM scott.emp
WHERE deptno = d.deptno
);You should be able to use either of these techiques to get the view you want. Your emp table corresponds to scott's dept table, and your courses table corresponds to scott's emp table. That is, you can have 0 or more courses per emp, in much the same way that scott can have 0 or more emps per dept.
Similar Messages
-
Table containing variants of query views
Dear SAP-experts,
I would like to know the table, where all the variants of query views are stored. I tried for "rsrparametriza", but it contains only the variants of queries and not its views.
Please help.
Best Regards,
Ram.Hi,
V_RSZGLOBV
Also check below link for the report related tables
http://wiki.sdn.sap.com/wiki/display/BI/ImportantTablesinSAPBI%28NW2004%29
It may help.
Regards,
Satya -
How can I combine post to two different tables with one form?
I am trying to create a "phantom" record in a table to be used later in a report. How can I create a form and properly $_POST to two different tables? Thanks for any suggestions!
In POST processing, just do the insert to one table, followed by the insert to the second table. I don't understand where you are getting stuck.
Sometimes when we do an insert, we need the auto-generated ID from the newly created record as a "foreign key" for the record created in the second insert. MySQL has a nifty solution for that. The specific code depends on whether you are using the mysql, mysqli or PDO database connection. -
Integrate different tables output into a unique table
Hello,
Please, I have the same BAPI in different systems with a table as output. I need to integrate in a unique table the outputs of the different tables (of each system) with VC 7. How can I do it?
Thanks in advance.Hi Belen,
You can use the UNION (if the table have the same output) or Combine (for table that have different field) in additionnal Operators under the Compose Panel. Basically the UNION have 2 tables view as input and 1 table View as output. You have to choose a key to determine how the table are combine. I hope this helps.
Vincent -
Different table used in infocube dataloading?
hii
we load data in to the cube by using star schema and extended star schema
here differnt data we have to load
here different ids like dimid and sid also generated
now my question is
1. which are the different table where the record and ids are stored?
2. how and when the dimid and sid are generated?
3. can we see the dim id and sid?if we can then where?
4. this ids are stored in which tables?
thanxxxHi Deepa,
Whenever you want to analyze the star schema of a particular cube, execute LISTSCHEMA transaction in your system. Once you execute this transaction you will see the list view of star schema and you will get to know all the underlying tables in which cube stores the data and reads data.
which are the different table where the record and ids are stored?
In case of infocube mainly Fact table and Dimension tables are used to store the transaction specific data.
2. how and when the dimid and sid are generated?
In the infocube design you can see the various dimensions and underlying characteristics in each dimension. During data loading one DIMID is created for each unique combination of all the characteristic values. Dimension table stores the SID's of each characteristic. For e.g. Your dimension consists of Material and customer then it will have different DIMID's as follows,
DIMID MATERIAL CUSTOMER
1 MAT1 CUST1
2 MAT1 CUST2
3 MAT2 CUST1 and so on.... In reality you will see SID's in DIM table.
3. can we see the dim id and sid?if we can then where?
You will have to check data in SID and DIM tables, use LISTSCHEMA transaction to get the table names.
4. this ids are stored in which tables?
SID and DIM tables.
Regards,
Durgesh. -
TREX - ECC 6.0 searches in different tables
Hi, have some search related questions:
- Is it possible to use TREX for combined searches from non-indexed tables in ECC 6.0 (where data is stored in different areas such as material, classification, BOM, customers, vendors, address data and so on)?
- Is it possible to mirror tables in ECC 6.0 to TREX via change pointers so the search data is "fresh" (the returned search result will be used in combination with other data and then stored back to ECC 6.0 from the NW portal)?
- Is it possible to have cross related search attributes (fields from material master, classification, bom, dms, address and so on) on the same tab in the sap standard search help (sap search help will be called from ABAP WebDynpro's)?
The main issue is to do combined searches with different combinations (number of input fields (10-20) related to different modules/areas) in ABAP WebDynpro. To do searches with outer table joins in tables without
keys and indexes seems not be doable.
/Brg Patrick OlssonHi lorenzo,
I have successfully installed ECC6.0 IDES SR2, i have found ECC-DIMP 6.0 LEVEL 6 in Support packs, please could you tell me that how can i activate IS-MILL in my server and what are the preconditions.
Thanks and Regards
ChandraB. -
Combining items with different fields
I have users that want to built a report that shows all the products in the same table. Problem is certain fields will only be populated for certain products.
For example, a table with 15 fields, first 5 are constant across both products, 2nd 5 only for product A, 3rd 5 only for product B.
When you select product A from a drop down they want the table to only show the first 10 fields, when you select product B they want the table to only show the first and last 5. If no product is selected all fields should show.
Am I right in thinking this could be achieved with the union to combine results?
ThanksAssuming that you have the same total number of columns for each product (in your example product A and B both have 10) then yes, you could use a UNION. The first part of the UNION would include the 5 common fields and the additional 5 that pertain to product A. The second part would have the common ones and also those that belong to B. You could include an extra column into which you'd store a string, either 'productA' or 'productB'. Then could then filter on this extra column to show the product you're interested in.
But if the number of columns isn't the same for both products that won't work. You could pull all the columns into the analysis and then create a separate table view for each product. You could exclude out whatever columns that don't make sense and then use a view selector to move between the different tables.
I guess it depends upon how you want to display the data. How many different products are there?
JB -
Best practice for a same query against 2 different tables
Hello all,
I want to extract info about tablespaces storage, both permanent and temporary. For that I use 2 different cursors that do exactly the same query but against a different table (dba_data_files and dba_temp_files).
CURSOR permanentTBSStorageInfo (tablespaceName VARCHAR2) IS
SELECT file_name, bytes, autoextensible, maxbytes, increment_by
FROM dba_data_files
WHERE tablespace_name = tablespaceName;
CURSOR temporaryTBSStorageInfo (tablespaceName VARCHAR2) IS
SELECT file_name, bytes, autoextensible, maxbytes, increment_by
FROM dba_temp_files
WHERE tablespace_name = tablespaceName;
First I'm bothered that I have to use 2 cursors to execute the same query against 2 different tables. Is there no another way around?
Then I fetch the results of this cursors in 2 different loops because I didn't find a way to dynamically call the cursors. I am looking for best practice here, knowing that I will do the same parsing against the results of the 2 cursors.
Thank you,Hi
Check whether the below query is helpful or not
select fs.tablespace_name "Tablespace",
fs.tempspace "Temp MB",
df.totalspace "Total MB"
from
(select
tablespace_name,
round(sum(bytes) / 1048576) TotalSpace
from
dba_data_files
group by
tablespace_name
) df,
(select
tablespace_name,
round(sum(bytes) / 1048576) tempSpace
from
dba_temp_files
group by
tablespace_name
) fs
where
df.tablespace_name = fs.tablespace_name;
Thanks -
How to create a foreign key for the table from two different tables?
Hi All,
I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK tables. See the below code 2
code 1:
CREATE TABLE SAMPLE_CONS_CHECK
(NAME VARCHAR2(10),
SERIES VARCHAR2(5)
CREATE TABLE SAMPLE_CONS2_CHECK
(NAME VARCHAR2(5),
MODEL NUMBER
CREATE TABLE SAMPLE_CONS3_CHECK
(NAME VARCHAR2(5),
MODEL_NO NUMBER
)code 2
alter table SAMPLE_CONS_CHECK
add constraint SAMPLE_CONS_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS2_CHECK
add constraint SAMPLE_CONS2_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS3_CHECK
add constraint SAMPLE_CONS3_CHECK_pk primary key (NAME)
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK1 FOREIGN KEY
NAME
) REFERENCES SAMPLE_CONS_CHECK
NAME
) ON DELETE CASCADE;
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK2 FOREIGN KEY
NAME
) REFERENCES SAMPLE_CONS2_CHECK
NAME
) ON DELETE CASCADE;From the above schenario i am able to insert the data to SAMPLE_CONS3_CHECK table. But the parent data is already available in the parent table. The problem is here two different constarints from two different tables. While inserting, it is checking from both the tables whether the parent is exist or not.
How can i solve this problem? Can anyone halp me about this?
Thanks
Edited by: orasuriya on Aug 8, 2009 2:02 AMActually the design is completely incorrect.
What you say is
I have
'foo', 'foo series'
'foo','foo model'
'foo',666
By virtue of table3 referring to both table1 and table2.
This means you actually need to have 1 (one) table:
'foo','foo series','foo model', 666
And the 'problem' disappears.
Sybrand Bakker
Senior Oracle DBA -
Report using Data from different tables
Hello,
I am trying to convert a Cobol batch program to Oracle 6i tabular report.
The data is fetched from many different tables and there are lots of processing(i.e, based on the value of a column from one table need additional processing from different tables) required to generate the desired columns in the final report.
I would like to know what is the best strategy to follow in Oracle Reports 6i. I heard that CREATE GLOBAL TEMPORARY TABLE is an option. ( or REF CURSOR ?) I do not know much about its usage. Can somebody guide me about this or any other better way to achieve the result.
Thank you in advance
PriyaHello,
There are many, many options available to you, each of which has advantages and disadvantages. This is why it is difficult to answer "what is best?" without alot more details about your specific circumstances.
In general, you're going to be writing PL/SQL to do any conditional logic that cannot be expressed as pure SQL. It can executed in the database, or it can executed within Reports itself. And most reports developers do some of both.
As a general rule, you want to send only the data you need from the database to the report. This means you want to do as much filtering and aggregating of the data as is readily possible within the database. If this cannot be expressed as plain SQL queries, then you'll want to create a stored procedures to help do this work.
Generally, the PL/SQL you create for executing within the report should be focused on control of the formatting, such as controlling whether a field is visible, or controlling display attributes for conditional formatting.
But these are not hard and fast rules. In some cases, it is difficult to get all the stored procedures you might like installed into the database. Perhaps the dba is reluctant to let you install that many stored procedures. Perhaps there are restrictions when and how often updates can be made to stored procedures in a production database, which makes it difficult to incrementally adjust your reports based on user feedback. Or perhaps there are restrictions for how long queries are allowed to run.
So, Reports offers lots of options and features to let you do data manipulation operations from within the report data model.
In any case, Oracle does offer temporary table capabilities. You can populate a temp table by running stored procedures that do queries, calculations and aggregations. And you can define and initiate a dynamic query statement within the database and pass a handle to this query off to the report to execute (ref cursor).
From the reports side, you can have as many queries as you want in the data model, arranged in any hierarchy via links. You can parameterize and change the queries dynamically using bind variables and lexicals. And you can add calculations, aggregations, and filters.
Again, most people do data manipulation both in the database and in Reports, using the database for what it excels at, and Reports for what it excels at.
Hope this helps.
Regards,
The Oracle Reports Team --skw -
How to join 5 different tables using SQL to make it to a flat file structur
I am trying to load five differnt tables into one flat file structure table without cartesian product.
I have five different tables Jobplan, Jobtask(JT), Joblabor(JL), Jobmaterial(JM) and Jpsequence(JS) and the target table as has all the five tables as one table.
The data i have here is something like this.
jobplan = 1record
jobtask = 5 records
joblabor = 2 records
jobmaterial = 1 record
jpsequence = 3 records
The output has to be like this.
JPNUM DESCRIPTION LOCATION JT_JPNUM JT_TASK JL_JPNUM JL_labor JM_JPNUM JM_MATERIAL JS_JPNUM JS_SEQUENCE
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 10 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 20 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 30 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 40 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 50 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA NULL NULL 1001 Sam NULL NULL NULL NULL
1001 Test Jobplan USA NULL NULL 1001 Mike NULL NULL NULL NULL
1001 Test Jobplan USA NULL NULL NULL NULL 1001 Hammer NULL NULL
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL 1001 1
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL 1001 2
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL 1001 3
Please help me out with this issue.
Thanks,
Siva
Edited by: 931144 on Apr 30, 2012 11:35 AMHope below helps you
CREATE TABLE JOBPLAN
( JPNUM NUMBER,
DESCRIPTION VARCHAR2(100)
INSERT INTO JOBPLAN VALUES(1001,'Test Jobplan');
CREATE TABLE JOBTASK
( LOCATION VARCHAR2(10),
JT_JPNUM NUMBER,
JT_TASK NUMBER
INSERT INTO JOBTASK VALUES('USA',1001,10);
INSERT INTO JOBTASK VALUES('USA',1001,20);
INSERT INTO JOBTASK VALUES('USA',1001,30);
INSERT INTO JOBTASK VALUES('USA',1001,40);
INSERT INTO JOBTASK VALUES('USA',1001,50);
CREATE TABLE JOBLABOR
( JL_JPNUM NUMBER,
JL_LABOR VARCHAR2(10)
INSERT INTO JOBLABOR VALUES(1001,'Sam');
INSERT INTO JOBLABOR VALUES(1001,'Mike');
CREATE TABLE JOBMATERIAL
( JM_JPNUM NUMBER,
JM_MATERIAL VARCHAR2(10)
INSERT INTO JOBMATERIAL VALUES(1001,'Hammer');
CREATE TABLE JOBSEQUENCE
( JS_JPNUM NUMBER,
JS_SEQUENCE NUMBER
INSERT INTO JOBSEQUENCE VALUES(1001,1);
INSERT INTO JOBSEQUENCE VALUES(1001,2);
INSERT INTO JOBSEQUENCE VALUES(1001,3);
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
JT.LOCATION AS LOCATION ,
JT.JT_JPNUM AS JT_JPNUM ,
JT.JT_TASK AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP, JOBTASK JT
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
JL.JL_JPNUM AS JL_JPNUM ,
JL.JL_labor AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP, JOBLABOR JL
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
JM.JM_JPNUM AS JM_JPNUM ,
JM.JM_MATERIAL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP, JOBMATERIAL JM
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
JS.JS_JPNUM AS JS_JPNUM ,
JS.JS_SEQUENCE AS JS_SEQUENCE
FROM JOBPLAN JP, JOBSEQUENCE JS;
JPNUM DESCRIPTION LOCATION JT_JPNUM JT_TASK JL_JPNUM JL_LABOR JM_JPNUM JM_MATERIA JS_JPNUM JS_SEQUENCE
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 10 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 20 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 30 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 40 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 50 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan NULL NULL NULL 1001 Sam NULL NULL NULL NULL
1001 Test Jobplan NULL NULL NULL 1001 Mike NULL NULL NULL NULL
1001 Test Jobplan NULL NULL NULL NULL NULL 1001 Hammer NULL NULL
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL 1001 1
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL 1001 2
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL 1001 3
{code} -
How to combine data from different input forms outside a nested iView
Hi,
i try to combine data from different input forms in a single one.
Because of space reasons in Flex compiling i already use nested iViews. Within these nested iViews its possible to use the 'combine' function to do this.
But in the main iView I cant compose these function with other elements. I need to do this because of using these model in Guided Procedures with output parameters. These parameters I only get with a 'endPoint'. Unfortunatly its not possible to combine data from different input forms into the 'endPoint'.
Is there any solution?
Thanx
MathiasHi Scott,
i tried this already and i also tried to map all parameters in the endpoint by drawing lines from the other forms and assign the 'empty parameters' by a formula.
And when i create a collable object in GP and assign the VC iView, only the parameters of the parent-form (the form who trigger the event) are shown as output-parameters.
Maybe any other ideas? I cant believe that such a simple thing is not possible?!?!
In my opinion, thats a bug, that I'am not able to use the combine-operator in the main VC-iView. Whats your mind?
greets
mathias -
Can i use one interface to load data into 2 different tables
Hi Folks,
Can i use one interface to load data into 2 different tables(same schema or different schemas) from one source table with same structure ?
Please give me advice
Thanks
Raj
Edited by: user11410176 on Oct 21, 2009 9:55 AMHi Lucky,
Thanks for your reply,
What iam trying is ...Iam trying to load the data from legacy tables(3) into oracle staging tables.But i need to load the same source data into two staging tables(these staging tables are in two different schemas)
can i load this source data into two staging tables by using single standard interface(some business logic is there)
If i can then give me some suggestion how to do that
Thanks in advance
Raj -
How can I use create/createInsert for two different tables
Hi All,
I am showing different fields in the UI from different tables. I am able to fetch the data from all the tables and able to modify and save the data.
Now, the problem when I want to create/insert some data into those columns(from different tables) I am facing issues.
How can I proceed further??Hi Shay,
Thank you very much for your quick response.
Actually I am totally new in ADF world and I am trying to implement some applications in ADF.
I created an UI based on some 3 tables(there is foreign key relation between them) and some other tables. I am able to modify and save my application if there is any data in all the tables.
My Actual issues are
1) I removed all the data from the tables. There is a submit(CreateInsert) button, what I expected is on click of the button I should see all the fields in editable mode. But I was able to see only few fields and also in readonly mode. So here my issue is how can i create and save these data.
2) Consider on my landing page I have just CommandLink/CommandButton. After clicking that page I should get the above screen in create mode(I mean to say all fields in editable mode). How can achieve this?
Thanks & Regards,
Ravi. -
How to use a USER_DATASTORE to index multiple columns in different tables
I would appreciate if somebody can give an example or point to links with examples on how to use USER_DATASTORE on multiple columns in different tables. THe Oracle Text documentation only shows multiple columns in the same table.
Thanks in advance.I am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.
Maybe you are looking for
-
I only have MS Word due to work, so I don't have Pages on my new Airbook (my old Powerbook had Pages, and that's where I created most of these documents), and would prefer not to have to install it if at all avoidable. Thanks. Teri
-
Creating a Transition Template for FCPX
So I am familiar with FCPX and editing, however I am still working on developing my skills in animated graphics. I found a great transition I want to brand my videos with but it is saved as a After Effects Project. Upon opening it AE just has transpa
-
How do I submit iBook updated version to iBooks store?
I have an iBook already in the store (free). I have an updated version ready to upload. Best way to do this? Thanks, JD
-
Please help.! Problem with locating classes within Jars under WEB-INF/lib.
Hi All, I have a problem which you guys would have faced already...Here it goes.. I'm using OC4J 10.1.3.0 and use ADF for my web page. I have a controller class which refers to JSF/ADF APIs and this class is archived as a jar file and put under WEB-I
-
I have uploaded pictures from my iPhone to iPhoto with a USB cable (you plug in, iPhoto shows you a tab with your iPhone's name, go there, click Import button). After the upload, It said that photos have been uploaded, but they are nowhere to be foun