www.webdeveloper.com
Results 1 to 3 of 3

Thread: customs columns in select statement and combinations of selects (Oracle)

  1. #1
    Join Date
    Nov 2009
    Posts
    2

    customs columns in select statement and combinations of selects (Oracle)

    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

  2. #2
    Join Date
    Oct 2009
    Posts
    658
    Quote Originally Posted by pnapp View Post
    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

    Code:
    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.
    Good Luck

    Santos Systems

  3. #3
    Join Date
    Nov 2009
    Posts
    2
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles