How to recode T-SQL without using Tally Table

Hello Community,

Can someone please help recode the following T-SQL such that I get the same result but without using Tally Table:

SELECT			RowNo AS PeriodNumber
                        ,Cost
				,Cost / 5 AS StraightLineDepreciation
				,Cost - ((Cost / 5) * RowNo) AS RemainingValue

FROM			Data.Stock				
CROSS APPLY
(
SELECT 1 AS RowNo
UNION ALL
SELECT 2
UNION ALL
SELECT 3
UNION ALL
SELECT 4
UNION ALL
SELECT 5
) Tally
WHERE			StockCode = 'A2C3B95E-3005-4840-8CE3-A7BC5F9CFB5F'

Thanks

please post sample data :slight_smile:

Maybe this link will help...

https://social.technet.microsoft.com/Forums/en-US/14db5ba7-0c50-44d1-9d6f-ff4c3dbeebe9/how-to-recode-tsql-without-tally-table?forum=transactsql

Is this for Spark SQL? If not - then why do you need to code it differently?

If for T-SQL you can use VALUES instead...

SELECT ...
FROM ...
(VALUES (1), (2), (3), (4), (5)) As t(n)