Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002
    Posts
    16

    Unanswered: Multiple SQL statements in a view

    Hi guys
    I was wondering if you could help me.

    I was wondering whether or not it is possible to have multiple sql statements within one view ?

    I tried the following :

    1> create view some_select_statements as
    2> select A,B,C,D from TABLE_A where A=1 and B=2011
    3> select A,B,C,D from TABLE_A where A=2 and B=2010
    4> go

    A B C D
    ------------- ----- ------ ---------
    1 2010 0 440000
    1 2010 0 450000

    (2 rows affected)
    1> select *from some_select_statements
    2> go
    A B C D
    ------------- ----- ------ ---------
    2 2011 0 430000

    (1 row affected)

    I was hoping for 3 rows from the view but only obtained 1.

    Any advice would be appreciated.

    Many Thanks
    Tony

  2. #2
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    You'd probably have to union them. but why not just change the SQL statement, e.g.
    WHERE ( A=1 and B=2011 ) or ( A=2 and B=2010 )
    Thanks,

    Matt

  3. #3
    Join Date
    Feb 2002
    Posts
    16
    Originally posted by MattR
    You'd probably have to union them. but why not just change the SQL statement, e.g.
    WHERE ( A=1 and B=2011 ) or ( A=2 and B=2010 )
    Thanks Matt
    Tony

Posting Permissions

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