Somehow can't figure this out:I have a table with a NVARCHAR (6) colomn DeliveryWeek. Most of the time this has a value like '200356' or '200210', but sometimes 'None'.Now I want I group by with some conditions SELECT DeliveryWeek, COUNT (*) FROM Oresys.dbo.tblAttribuut aWHERE DeliveryWeek IS NOT NULL AND ISNUMERIC (AFleverweek) = 1AND CAST (DeliveryWeek AS INT) BETWEEN DatePart (ww, GetDate()-7) AND DatePart (ww,GetDate() + 105)GROUP BY DeliveryWeek
This produces an error:Syntax error converting the nvarchar value 'None' to a column of data type int.Even if I use this in my where clauseWHERE (CASE WHEN (a.DeliveryWeek IS NOT NULL AND ISNUMERIC (a.DeliveryWeek) = 1) THEN CAST (a.DeliveryWeek AS INT) ELSE 0 END BETWEEN DatePart (ww,GETDATE() - 14) AND DatePart (ww,GETDATE() + 105) )
What should I do?Henri~~~SQL is nothing, writing it everything.Edited by - henrikop on 07/09/2003 10:43:17