Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Nested Select problem

Author  Topic 

nmarks
Yak Posting Veteran

53 Posts

Posted - 2008-05-14 : 09:37:08
I've become stuck on a nested SELECT statement.

The actual statement I'm working on is more complicated than the one below but I get the same error on this one too.

Can anyone tell me how to correct the code below please?

When I try to parse the SQL I error this error :
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near ')'.

Here's the code:


SELECT
Duration
, A * B * C AS Life1
INTO #sp
FROM
(SELECT
Duration = Duration
, A = 1
, B = 2
, C = 3
FROM emt_Duration_Months)

nmarks
Yak Posting Veteran

53 Posts

Posted - 2008-05-14 : 09:42:27
By the way emt_Duration_Months is a table the counts 1, 2, 3 . . . 720.
Go to Top of Page

nmarks
Yak Posting Veteran

53 Posts

Posted - 2008-05-14 : 09:42:28
By the way emt_Duration_Months is a table the counts 1, 2, 3 . . . 720.
Go to Top of Page

nmarks
Yak Posting Veteran

53 Posts

Posted - 2008-05-14 : 09:42:28
By the way emt_Duration_Months is a table the counts 1, 2, 3 . . . 720.
Go to Top of Page

nmarks
Yak Posting Veteran

53 Posts

Posted - 2008-05-14 : 09:42:31
By the way emt_Duration_Months is a table the counts 1, 2, 3 . . . 720.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-14 : 10:05:16
quote:
Originally posted by nmarks

I've become stuck on a nested SELECT statement.

The actual statement I'm working on is more complicated than the one below but I get the same error on this one too.

Can anyone tell me how to correct the code below please?

When I try to parse the SQL I error this error :
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near ')'.

Here's the code:


SELECT
t.Duration
, t.A * t.B * t.C AS Life1

INTO #sp
FROM
(SELECT
Duration = Duration
, A = 1
, B = 2
, C = 3
FROM emt_Duration_Months)t


Try with an alias. I still cant understand the purpose of derived table though.
Go to Top of Page

stixoffire
Starting Member

17 Posts

Posted - 2008-05-14 : 16:37:26
quote:
Originally posted by nmarks

I've become stuck on a nested SELECT statement.

The actual statement I'm working on is more complicated than the one below but I get the same error on this one too.

Can anyone tell me how to correct the code below please?

When I try to parse the SQL I error this error :
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near ')'.

Here's the code:


SELECT
Duration
, A * B * C AS Life1
INTO #sp
FROM
(SELECT
Duration = Duration
, A = 1
, B = 2
, C = 3
FROM emt_Duration_Months)


Try this - as strange as it might sound
SELECT
Duration
, A * B * C AS Life1
INTO #sp
FROM
(SELECT
Duration = Duration
, A = 1
, B = 2
, C = 3
FROM emt_Duration_Months
Group By Duration)
Go to Top of Page

nmarks
Yak Posting Veteran

53 Posts

Posted - 2008-05-14 : 22:34:03
visakh16 - the alias worked. Thanks.

Thanks also to stixoffire for your suggestion.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-18 : 13:30:58
quote:
Originally posted by nmarks

visakh16 - the alias worked. Thanks.

Thanks also to stixoffire for your suggestion.


You're welcome. What was purpose of derived table?
Go to Top of Page
   

- Advertisement -