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
 General SQL Server Forums
 New to SQL Server Programming
 Msg 102, Level 15, State 1, Line 31

Author  Topic 

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-09-01 : 13:57:12
I am having trouble fixing the code below, i'm getting the following error message

Msg 102, Level 15, State 1, Line 31
Incorrect syntax near 'G (Determine GL3)'.


SELECT [code allocation].[code Id],
Min([code allocation].[G Code]) AS [G4],
Min([code allocation].[sumofGL Perc of Cost]) AS [G4 perc of cost],
[G (Determine GL1)].[Code Id] AS [GL1],
[G (Determine G1)].[G1],
[G (Determine G1)].[G1 perc of cost],
[G (Determine G2)].[G2 Code Id] AS [Load G2],
[G (Determine G2)].[G2],
[G (Determine G2)].[G2 perc of cost],
[G (Determine G3)].[G3 Code Id] AS [Load G3],
[G (Determine G3)].[G3],
[G (Determine G3)].[G3 perc of cost]
INTO [G (Determine G4)]
FROM [code allocation]
LEFT JOIN [G (Determine GL1)]
ON ([code allocation].[Code Id] = [G (Determine GL1)].[Code Id])
AND ([code allocation].[GL Code] = [G (Determine GL1)].[GL1])
LEFT JOIN [G (Determine GL2)]
ON ([code allocation].[Code Id] = [G (Determine GL2)].[Code Id])
AND ([code allocation].[GL Code] = [G (Determine GL2)].[GL2])
LEFT JOIN [G (Determine GL3)]
ON ([code allocation].[Code Id] = [G (Determine GL3)].[Code Id])
AND ([code allocation].[GL Code] = [G (Determine GL3)].[GL3])
GROUP BY [code allocation].[Code Id],
[G (Determine GL1)].[Code Id],
[G (Determine GL1)].[GL1],
[G (Determine GL1)].[GL1 perc of cost],
[G (Determine GL2)].[GL2 Code Id],
[G (Determine GL2)].[GL2],
[G (Determine GL2)].[GL2 perc of cost]
[G (Determine GL3)].[GL3 Code Id],
[G (Determine GL3)].[GL3],
[G (Determine GL3)].[GL3 perc of cost]
HAVING (([G (Determine GL1)].[Code Id]) IS NULL)
AND (([G (Determine GL1)].[GL1]) IS NULL)
AND (([G (Determine GL1)].[GL1 perc of cost]) IS NULL)
AND (([G (Determine GL2)].[GL2 Code Id]) IS NULL)
AND (([G (Determine GL2)].[GL2]) IS NULL)
AND (([G (Determine GL2)].[GL2 perc of cost]) IS NULL)
AND (([G (Determine GL3)].[GL3 Code Id]) IS NULL)
AND (([G (Determine GL3)].[GL3]) IS NULL)
AND (([G (Determine GL3)].[GL3 perc of cost]) IS NULL);

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-01 : 14:02:35
quote:
Originally posted by rob41

I am having trouble fixing the code below, i'm getting the following error message

Msg 102, Level 15, State 1, Line 31
Incorrect syntax near 'G (Determine GL3)'.


SELECT [code allocation].[code Id],
Min([code allocation].[G Code]) AS [G4],
Min([code allocation].[sumofGL Perc of Cost]) AS [G4 perc of cost],
[G (Determine GL1)].[Code Id] AS [GL1],
[G (Determine G1)].[G1],
[G (Determine G1)].[G1 perc of cost],
[G (Determine G2)].[G2 Code Id] AS [Load G2],
[G (Determine G2)].[G2],
[G (Determine G2)].[G2 perc of cost],
[G (Determine G3)].[G3 Code Id] AS [Load G3],
[G (Determine G3)].[G3],
[G (Determine G3)].[G3 perc of cost]
INTO [G (Determine G4)]
FROM [code allocation]
LEFT JOIN [G (Determine GL1)]
ON ([code allocation].[Code Id] = [G (Determine GL1)].[Code Id])
AND ([code allocation].[GL Code] = [G (Determine GL1)].[GL1])
LEFT JOIN [G (Determine GL2)]
ON ([code allocation].[Code Id] = [G (Determine GL2)].[Code Id])
AND ([code allocation].[GL Code] = [G (Determine GL2)].[GL2])
LEFT JOIN [G (Determine GL3)]
ON ([code allocation].[Code Id] = [G (Determine GL3)].[Code Id])
AND ([code allocation].[GL Code] = [G (Determine GL3)].[GL3])
GROUP BY [code allocation].[Code Id],
[G (Determine GL1)].[Code Id],
[G (Determine GL1)].[GL1],
[G (Determine GL1)].[GL1 perc of cost],
[G (Determine GL2)].[GL2 Code Id],
[G (Determine GL2)].[GL2],
[G (Determine GL2)].[GL2 perc of cost],
[G (Determine GL3)].[GL3 Code Id],
[G (Determine GL3)].[GL3],
[G (Determine GL3)].[GL3 perc of cost]
HAVING (([G (Determine GL1)].[Code Id]) IS NULL)
AND (([G (Determine GL1)].[GL1]) IS NULL)
AND (([G (Determine GL1)].[GL1 perc of cost]) IS NULL)
AND (([G (Determine GL2)].[GL2 Code Id]) IS NULL)
AND (([G (Determine GL2)].[GL2]) IS NULL)
AND (([G (Determine GL2)].[GL2 perc of cost]) IS NULL)
AND (([G (Determine GL3)].[GL3 Code Id]) IS NULL)
AND (([G (Determine GL3)].[GL3]) IS NULL)
AND (([G (Determine GL3)].[GL3 perc of cost]) IS NULL);






Missed a ,

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-09-01 : 14:06:30
thanks :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-01 : 14:06:59
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -