Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Shift month numbers for FY start
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00929339
Message ID:
00929411
Vues:
10
This message has been marked as a message which has helped to the initial question of the thread.
Hi Mike,

No, SET command can be used in T-SQL but not in SELECT. Here's the version for SELECT, assuming that @fystart is a loacl variable.
SELECT CASE WHEN (MonthNum + @fystart) = 13 THEN 12 
  ELSE ((MonthNum + @fystart - 1) % 12)  END AS RealMonth ...
>>
>>Try
SET @RealMonth = (@MonthNum + @fystart - 1) % 12
>>CASE @RealMonth WHEN 0 THEN 12 ELSE RealMonth END
>>
>>
>Uhh... OK, but how do I include that within my TSQL select command...
>
>Is it something like this:
>
>
>SET @RealMonth = (@MonthNum + @fystart - 1) % 12
>CASE @RealMonth WHEN 0 THEN 12 ELSE RealMonth END
>SELECT     STR(@RealMonth, 2, 0) + ' - ' + MonthName AS DisplayValue, STR(@RealMonth, 2, 0) AS cValue
>FROM         SelectLists
>
>
>... or does the SET... END statement belong within the SELECT somehow? (Pardon my neophite SQL status)
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform