Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find the month status
Message
De
12/09/2007 09:24:21
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
11/09/2007 13:05:36
Issam Mansour
Jordan Business Machines
Amman, Jordanie
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01253723
Message ID:
01253899
Vues:
19
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform