thub.users.profile.tabs.comments.personalized


Try this:

 DECLARE @StartDate date;
 DECLARE @EndDate date;
 SELECT @StartDate = MIN([Month]), @EndDate = MAX([Month]) FROM #Test
    
 ;WITH CTE_Date AS (
     SELECT @StartDate AS [Month]
     UNION ALL
     SELECT DATEADD(MONTH, 1, [Month]) AS [Month]
     FROM CTE_Date
     WHERE [Month] < @EndDate
 ),
 CTE_Distinct_C1_And_Region AS (
     SELECT DISTINCT C1, Region
     FROM #Test
 ),
 CTE_Date_C1_Region AS (
     SELECT [Month], C1, Region
     FROM CTE_Date, CTE_Distinct_C1_And_Region
 ),
 CTE AS (
     SELECT
         CASE 
             WHEN t.FiscalYear IS NULL THEN 
                 CASE WHEN MONTH(c.[Month]) >= 9 THEN YEAR(c.[Month]) + 1 ELSE YEAR(c.[Month]) END
             ELSE t.FiscalYear 
         END AS FiscalYear,
         c.[Month],
         c.Region,
         c.C1,
         ISNULL(t.MTD, 0) AS MTD
     FROM CTE_Date_C1_Region AS c
     LEFT JOIN #Test AS t ON c.[Month] = t.[Month] AND c.Region = t.Region AND c.C1 = t.C1
 )
    
 SELECT FiscalYear,  [Month], Region, C1, MTD, 
 SUM(CASE WHEN FiscalYear = YEAR([Month]) THEN MTD ELSE 0 END) OVER(PARTITION BY Region, C1 ORDER BY [Month] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS YTD
 FROM CTE
 ORDER BY [Month], [C1], [Region];


230819-image.png



image.png (10.9 KiB)

You should also get both 2021-10-01 00:00:00.000 and 2021-12-31 00:00:00.000.

Try this:

 DECLARE @dateEntered date = '2022-03-02';
 SELECT DATEADD(qq, DATEDIFF(qq, 0, @dateEntered) - 1, 0) AS First_Date_of_Previous_Quarter, 
        DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, @dateEntered), 0)) AS Last_Date_of_Previous_Quarter,
        DATEADD(qq, DATEDIFF(qq, 0, @dateEntered), 0) AS First_Date_of_Current_Quarter, 
        DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, @dateEntered) + 1, 0)) AS Last_Date_of_Current_Quarter;

Based on your sample data, the column numbers are different for each string?

What is the output you expected based on your sample data?

Please post each table DDL and sample data based on your output from your screenshot (https://docs.microsoft.com/en-us/answers/storage/attachments/196639-422project-2.png). So we can do the test.

Close your SSMS and reopen it using "Run as administrator" (right click on SSMS) and then re-try it. Wondering if it is an authentication issue.

Are you able to import your .dtsx file to your project?

Make sure you have the SSIS installed. From VS, click on the tab "Extensions" and select "Manage Extensions". Check if the SSIS is installed:

193150-image.png


image.png (7.7 KiB)

You can follow the steps in this article "Creating the SSIS Catalog".


Since the column GuestId exists in all three tables of KidsClubReservation, KidsClubGuest and KidsClubChild which are used in the SELECT statement in the subquery, you need to use an alia before the column names instead of SELECT *.

Not clear to your question. Are you saying that you need a dynamic script to create a table and a script to insert data into that table?

See my updated answer.

Or if you change SELECT string to PRINT string you would be able to see two line of the output:

 PRINT('first line ' + char(13) + char(10) +
 'second line ')

188871-image.png


image.png (5.0 KiB)

Is there a comma after Student (Student. | ...)?