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 11Incorrect syntax near ')'.Here's the code:SELECT Duration , A * B * C AS Life1INTO #spFROM (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. |
 |
|
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. |
 |
|
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. |
 |
|
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. |
 |
|
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 11Incorrect syntax near ')'.Here's the code:SELECT t.Duration , t.A * t.B * t.C AS Life1INTO #spFROM (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. |
 |
|
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 11Incorrect syntax near ')'.Here's the code:SELECT Duration , A * B * C AS Life1INTO #spFROM (SELECT Duration = Duration , A = 1 , B = 2 , C = 3 FROM emt_Duration_Months)
Try this - as strange as it might soundSELECTDuration, A * B * C AS Life1INTO #spFROM(SELECT Duration = Duration, A = 1, B = 2, C = 3FROM emt_Duration_MonthsGroup By Duration) |
 |
|
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. |
 |
|
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? |
 |
|
|