Hi,@pizaro
Welcome to Microsoft T-SQL Q&A Forum!
Please check this:
SELECT VENDOR,TYPE,start_date
CASE
WHEN MONTH(start_date) IN (1,2,3) THEN 'Detail'+'_'+convert(char(4), YEAR(start_date)) +'_' + 'Q1'
WHEN MONTH(start_date) IN (4,5,6) THEN 'Detail'+'_'+convert(char(4), YEAR(start_date))+'_' + 'Q2'
WHEN MONTH(start_date) IN (7,8,9) THEN 'Detail'+'_'+convert(char(4), YEAR(start_date)) +'_'+ 'Q3'
WHEN MONTH(start_date) IN (10,11,12) THEN 'Detail'+'_'+convert(char(4), YEAR(start_date))+'_' + 'Q4'
END AS DynamicColumn
FROM Filemain
where year(start_date )= 2022
Best regards,
Bert Zhou
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.