Salut,

Dans le code qui suit je souhaite considérer tous les mois passés comme le mois actuel. En d'autres termes si il y a des enregistrements du mois de décembre je souhaiterais les voir apparaître comme janvier 2008 ( sous le format 200801 d'ou : THEN (CONVERT(CHAR(6), dateadd(M,0,getdate()), 112))

Toujours est-il que cela ne fonctionne pas

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
CREATE VIEW dbo.[OPEN]
AS
SELECT 
 
[SIOP_Daily_Picture].[dbo].[fiscal_date].[Year_Month] as [YEAR_MONTH], 
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[ITEM_ID] AS [Item],
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[LOC_ID] AS [Dist_Node]
 
CASE
WHEN ((CONVERT(CHAR(6), [LVSDB].[dbo].[SCP_CUST_ORD_STUB].[CUST_ORD_DATE], 112))<=(CONVERT(CHAR(6), dateadd(M,0,getdate()), 112))
THEN (CONVERT(CHAR(6), dateadd(M,0,getdate()), 112))
END
 
FROM [LVSDB].[dbo].[SCP_CUST_ORD_STUB]
INNER JOIN [SIOP_Daily_Picture].[dbo].[fiscal_date]
 
ON [LVSDB].[dbo].[SCP_CUST_ORD_STUB].[CUST_ORD_DATE] = [SIOP_Daily_Picture].[dbo].[fiscal_date].[Date]
 
GROUP BY [SIOP_Daily_Picture].[dbo].[fiscal_date].[Year_Month],
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[ITEM_ID],
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[LOC_ID]
 
GO
Merci d'ores est déjà pour les solutions amenées jusque là et qui sait : peut être un nouveau miracle

bon ben lorsque j'essaie avec ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
CREATE VIEW dbo.[OPEN]
AS
SELECT 
 
CASE [SIOP_Daily_Picture].[dbo].[fiscal_date].[Year_Month]
WHEN (CONVERT(CHAR(6), [LVSDB].[dbo].[SCP_CUST_ORD_STUB].[CUST_ORD_DATE], 112))<=(CONVERT(CHAR(6), dateadd(M,0,getdate()), 112))
THEN (CONVERT(CHAR(6), dateadd(M,0,getdate()), 112))
END
as [YEAR_MONTH], 
 
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[ITEM_ID] AS [Item],
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[LOC_ID] AS [Dist_Node]
 
FROM [LVSDB].[dbo].[SCP_CUST_ORD_STUB]
INNER JOIN [SIOP_Daily_Picture].[dbo].[fiscal_date]
 
ON [LVSDB].[dbo].[SCP_CUST_ORD_STUB].[CUST_ORD_DATE] = [SIOP_Daily_Picture].[dbo].[fiscal_date].[Date]
 
GROUP BY [SIOP_Daily_Picture].[dbo].[fiscal_date].[Year_Month],
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[ITEM_ID],
[LVSDB].[dbo].[SCP_CUST_ORD_STUB].[LOC_ID]
cela ne fonctionne pas non plus