Click here to Skip to main content
14,427,400 members
Rate this:
Please Sign up or sign in to vote.
See more:
getting syntax error : Incorrect syntax near '('

What I have tried:

Select distinct ls.lot_ID, ls.product_ID, ls.product_name, ls.current_step, m.RdmMaterialName,f.RouteName,MTTS
From [MMY_MFG_WIP].[dbo].LotStatus ls
Left Join [MMY_MFG_WIP].[dbo].Material m on product_name=m.Name and m.RdmMaterialName is not null
left join [MMY_MFG_WIP].[dbo].[Route] f on m.RdmMaterialName=f.MaterialName
left join (Select cast(sum( k.CycleTime)/86400 as decimal (10,2) ) as CycleTime from [MMY_MFG_WIP].[dbo].[Vertex] k where k.RouteName = RouteName
and k.Sequence > (SELECT Sequence
FROM [MMY_MFG_WIP].[dbo].[Vertex] v right join [MMY_MFG_WIP].[dbo].[LotStatus] on v.StepName=current_step and v.RouteName=k.RouteName
group by v.RouteName,Sequence)) as cast (decimal(18,1)) as MTTS
Posted
Updated 5 days ago

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

With you formatting cleaned up, sub-queries indented, and capitalizing keywords to make them stand out, it becomes pretty obvious that you've got mismatched paranthesis:
SELECT distinct ls.lot_ID
     , ls.product_ID
     , ls.product_name
     , ls.current_step
     , m.RdmMaterialName
     , f.RouteName
     , MTTS
FROM [MMY_MFG_WIP].[dbo].LotStatus AS ls
LEFT JOIN [MMY_MFG_WIP].[dbo].Material AS M
ON product_name=m.Name AND m.RdmMaterialName IS NOT NULL
LEFT JOIN [MMY_MFG_WIP].[dbo].[Route] AS F
ON m.RdmMaterialName=f.MaterialName
LEFT JOIN (
	SELECT (SUM(k.CycleTime)/86400 AS decimal(10,2)) AS CycleTime
	FROM [MMY_MFG_WIP].[dbo].[Vertex] AS K
	WHERE k.RouteName = RouteName AND k.Sequence > (
		SELECT Sequence
		FROM [MMY_MFG_WIP].[dbo].[Vertex] AS v
		RIGHT JOIN [MMY_MFG_WIP].[dbo].[LotStatus]
		ON v.StepName=current_step AND v.RouteName=k.RouteName
		GROUP BY v.RouteName, Sequence
	)
) AS CAST (decimal(18,1)
) as MTTS

What's going on with the last couple of lines of the query? You've got an open parenthesis starting at the LEFT JOIN, but two close parenthesis at the end of the query.
   
v2
Comments
Richard MacCutchan 5 days ago
   
Dave, there was a spam message below which contained your full name. So, if you suddenly find your messages are getting trapped by the spam filter you know why.
Dave Kreskowiak 5 days ago
   
That's cute. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100