SQL Puzzle 8: Find the Fiscal Year of Employee Joined the Company

SAS
0

In this SQL puzzle, we challenge you to determine the fiscal year in which an employee joined a company, considering that the fiscal year runs from April to March


Input Data:



Expected Output:



Data Script:


CREATE TABLE #Empliyee
(
EmpID INT,
EmpName NVARCHAR(250),
DOJ DATE,
DOB DATE
)

INSERT INTO #Empliyee
VALUES
(1010,'Arayan','2020-09-29','1991-01-01'),
(1020,'Rajjab','2018-01-04','1989-05-28'),
(1030,'Shyam','2023-03-31','1992-04-14'),
(1040,'Sandy','2015-12-26','1985-12-26'),
(1050,'Latha','1999-02-25','1979-02-25'),
(1060,'Andru','1999-10-10','1978-10-10')


SELECT * FROM #Empliyee

Please try to answer the question, if you still not able to get it click below show button to see the answer.

SELECT *,
	CASE WHEN MONTH(DOJ) BETWEEN 1 AND 3 THEN CONCAT('FY - ',CAST(YEAR(DOJ)-1 AS NVARCHAR(4)))
	ELSE CONCAT('FY - ',CAST(YEAR(DOJ) AS NVARCHAR(4))) END AS DOJ_FiscalYear
FROM #Empliyee

Tags:

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Check Now
Ok, Go it!