Skip to Content
Former Member
Feb 19, 2004 at 04:06 PM

Multiple options within a query


I'm trying to create a new query within SBO where depending upon the outcome of a question will query against one set of data or the other.

Does anyone know where I've gone wrong with the code below?

SELECT dbo.OCRD.CardCode AS Code, dbo.OCRD.CardName AS Client, dbo.OCRD.CntctPrsn AS Contact, dbo.OCRD.Phone1 AS Phone, dbo.OCRD.Cellular AS Mobile, dbo.OCRD.CreditLine, dbo.OCRD.DebtLine, dbo.OCRD.Balance, '[%1]' as stuff

FROM dbo.OCRD INNER JOIN dbo.OSLP ON dbo.OCRD.SlpCode = dbo.OSLP.SlpCode

WHERE ((dbo.OCRD.CardType = 'C') OR (dbo.OCRD.CardType = 'L')) AND dbo.OCRD.Balance > (CASE WHEN [%1] = 'A' THEN dbo.OCRD.CreditLine ELSE dbo.OCRD.DebtLine END)