Click to See Complete Forum and Search --> : customs columns in select statement and combinations of selects (Oracle)


pnapp
11-19-2009, 07:10 AM
Hi,

I am trying to combine two reports (select statements) into one. Say I have one report, which has columns named A,B,C coming from some tables and a second report with columns B,C,D coming from some other tables. Now I want a report with columns A,B,C,D.

My first Idea (don't know, if this is the right way to do it), is to use somehow a union statement with the two selects I have.

For this I need to to expand the first select by a custom column named D and the second by a custom column named A.

How do I use a "select" together with custom columns. In Access I can do something like

"select A,B,C, null as "D" from some_table".

This would give me
A |B |C |D|
some value |some value |some value | |
some value |some value |some value | |


Then I do the same with my second select expanding it by an "A"-column and use a union.

How can I do this with an oracle database (later I will use Crystal Reports to generate the report)

Any hint/advise is greatly appreciated.

Peter

ssystems
11-19-2009, 01:20 PM
Hi,
My first Idea (don't know, if this is the right way to do it), is to use somehow a union statement with the two selects I have.


You might want to read more on TSQL Joins


select
t1.A A
,t1.B B
,t2.C C
,t2.D D
from
t1,t2
where
t1.B = t2.B
and t1.C = t2.C


Additionally since you'll use CR then this would be a lot easier as it already have mechanism for this. Check out the links tab of your report.

pnapp
11-20-2009, 08:55 AM
Hi,

thank you for your answer.

I can not do a join, because there is not necessarily a logical connection between t1.B and t2.B. I just want them to be reported in the same column.

I found the way how to add a custom column in oracle. It basically works las in Access:

select null as A, B, C from t1

will do it, i.e. add an empty column A

Pete