Monday, March 19, 2012

Decode in SQL Server

Hi

I have oracle statement and I want to translate it in SQL Server:

select DECODE(count(bid_Vendor), 1, NULL, COUNT(BID_VENDOR))
from bid_total

I tried it this way:
Select case(count(bid_vendor) when 1 then null else count(bid_vendor)end) as cs from bid_total

It gave me error i.e.

Incorrect syntax near the keyword 'when'Select CASE count(bid_vendor)
WHEN 1 then null
ELSE count(bid_vendor)
END as cs
FROM bid_total-PatP

No comments:

Post a Comment