April 27, 2010 at 1:56 am
Hi,
I have a query similar to the below
SELECT StartDate, InvoiceDate
FROM TableA
Where CASE WHEN InvoiceDate > StartDATE
THEN StartDate <= @Date
ELSE InvoiceDate <= @Date
END
This query does not actually work and I'm struggling work out how to get the desired results. I basically want to use, in the where clause, the column StartDate if the InvoiceDate is > StartDate else use InvoiceDate.
Can anyone help me with this?
Thanks.
April 27, 2010 at 2:12 am
Buddy, can you be more specific with your requirement?? i mean, why do u wnat to compare the InvoiceDate and StartDate and then again using the same combination to filter out records?
Please give us some more visual samples and sample data to work around.. also the desired result which u want to see...
April 27, 2010 at 2:53 am
I agree with Mr Coffee - it's not entirely clear what is being asked, but this is my guess:
SELECT StartDate, InvoiceDate
FROM @Table
WHERE @Date >
CASE
WHEN InvoiceDate > StartDate THEN StartDate
ELSE InvoiceDate
END;
This is not a high-performance construction. Please share more details about the problem to get a better answer.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply