Snapshot yearly to snapshot quarterly

Nhu Nguyen Ngoc Quynh 20 Reputation points

Hello All,

I have a data table as below which has Date as yearly.


Required solution


Now my requirement is I need to create a query to create quarterly data from the yearly data (by duplicating the yearly data details for each ID)
As I have 12 months data here i need to show 4 quarters data.

Could any one please help how to do? Thank you so much.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,895 questions
0 comments No comments
{count} votes

Accepted answer
  1. CosmogHong-MSFT 23,716 Reputation points Microsoft Vendor

    Hi @Nhu Nguyen Ngoc Quynh

    Please check this query:

    create table #data ([Date] int,ID int ,Field1 varchar(10),Field2 varchar(10),Field3 varchar(10))
    insert into #data values
    SELECT CONCAT(LEFT([Date],4),[Quarter])AS Year_Quarter,ID,Field1,Field2,Field3
    FROM #data CROSS APPLY (VALUES('03'),('06'),('09'),('12'))C([Quarter])

    Best regards,

    Cosmog Hong

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful