>Hi,
>
>I have a table shows 12 month and the status of each month if it's closed of not, how to find the last month closed in a SQL Staement, the file looks like this:-
>
>year 1 2 3 4 5 6 7 8 9 10 11 12
>2007 T T T T T T T T F F F F
>
>
>the field name are not numbers its just for the example
You're using SQL2005, you can unpivot the data and do a simple min() query. Or this would work too:
select [year], closingMonth = case
when m1 = 0 then 1
when m2 = 0 then 2
...
when m12 = 0 then 12
else
null
end
from myTable
Cetin