select from subquery

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MarekD

    select from subquery

    Hi.
    I'm new in SqlServer programing.
    Is it possible to do something like this ( It is common construction in oracle )

    Select X from(
    select a+1 as X from tab1
    )

    without creating view containig subquery ?

    thx. MD
  • Simon Hayes

    #2
    Re: select from subquery


    "MarekD" <marekdull@pocz ta.onet.pl> wrote in message
    news:54c8df1c.0 502071133.7cc6b f62@posting.goo gle.com...[color=blue]
    > Hi.
    > I'm new in SqlServer programing.
    > Is it possible to do something like this ( It is common construction in
    > oracle )
    >
    > Select X from(
    > select a+1 as X from tab1
    > )
    >
    > without creating view containig subquery ?
    >
    > thx. MD[/color]

    Yes, but you need to give the derived table an alias:

    Select X from(
    select a+1 as X from tab1
    ) dt

    Simon



    Comment

    • louis

      #3
      Re: select from subquery

      Yes. Check out this article:
      http://www.microsoft.com/technet/pro.../sqlorcle.mspx.

      With MSSQL, you'll need an alias.

      Select X from(
      select a+1 as X from tab1
      ) as myAlias

      Comment

      Working...