Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorrect syntax near keyword Select 1

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
I'm having some syntax problems with this query. I've gotten most of it worked out but still get this error.
Code:
ERROR 156: Incorrect syntax near keyword 'SelecT'
Incorrect syntax ner keyword 'aS'

I've tried to correct it but I can't seem to get it right. Can someone offer any suggestions.

Code:
SELECT A.[ID], A.StorageLoc, A.SLRRawCardPN, A.StencilPartNumber, A.StencilRev, A.Customer, A.SLRPartNumber,
    A.JobNumber, A.Comments, A.DispositionedAs, A.DispositionedBy, A.DispositionedDate 
    FROM tblStencils AS A  INNER JOIN 
   [b]SelecT[/b] StencilPartNumber,NOLONGERNEEDED,Left(StencilRev,1) as f2 FROM tblStencils 
    GROUP BY StencilPartNumber,NOLONGERNEEDED, Left(Stencilrev,1) HAVING Count(*)>1 AND NOLONGERNEEDED=0 [b]aS[/b] B  
    ON A.StencilPartNumber = B.StencilPartNumber
    WHERE A.StorageLoc Like 'SS%'
   AND A.Customer=@Customer
   AND Left([StencilRev],1)=B.f2
   AND A.NoLongerNeeded=0 
   ORDER BY A.StencilPartNumber, A.StencilRev
 
I think that you miss some "(" and ")".
Code:
SELECT A.[ID], A.StorageLoc, A.SLRRawCardPN, A.StencilPartNumber, A.StencilRev, A.Customer, A.SLRPartNumber,
    A.JobNumber, A.Comments, A.DispositionedAs, A.DispositionedBy, A.DispositionedDate 
    FROM tblStencils AS A  INNER JOIN 
   [b]([/b]Select StencilPartNumber,NOLONGERNEEDED,Left(StencilRev,1) as f2 FROM tblStencils 
    GROUP BY StencilPartNumber,NOLONGERNEEDED, Left(Stencilrev,1) HAVING Count(*)>1 AND NOLONGERNEEDED=0[b])[/b] aS B  
    ON A.StencilPartNumber = B.StencilPartNumber
    WHERE A.StorageLoc Like 'SS%'
   AND A.Customer=@Customer
   AND Left([StencilRev],1)=B.f2
   AND A.NoLongerNeeded=0 
   ORDER BY A.StencilPartNumber, A.StencilRev

-------------------------------------------------------------------------------------------------------------------------
"Now I can look at you in peace; I don't eat you any more." Franz Kafka, while admiring fish in an aquarium
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top