0

I was running this query in MSSQL:

SELECT * FROM (SELECT * FROM ABC) 

It gives an error:

Msg 102, Level 15, State 1, Line 1

Incorrect syntax near ')'.

This same command runs just fine on a DB2 database. I know this query doesn't make any sense I was just testing functionality.

So, are there certain features, eg., SELECT in FROM clause, that are not supported in MSSQL that are supported in DB2?

1
  • 3
    Try putting an alias on the subquery: SELECT * FROM (SELECT * FROM ABC) AS t. Commented Mar 18, 2015 at 13:13

1 Answer 1

3

You just need to give the subquery an alias like so:

SELECT * FROM (SELECT * FROM ABC) subTable

Which translates to:

SELECT * FROM (SELECT * FROM ABC) as subTable

The AS is optional.

Sign up to request clarification or add additional context in comments.

1 Comment

Whilst the As is optional, missing it out is lazy and can cause lots of confusion! "If you don't alias it, it don't get in production"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.