Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Thursday, September 28, 2017 6:26 AM
i receive two decimal values from frontend,
a=0.98 or 01.02
b=01.02 or 0.98
i want to generate range between that two numbers
expected output-0.98,0.99,01.00,01.01,01.02
note that
i want to generate the range between two decimal numbers
Thursday, September 28, 2017 6:56 AM
See your other thread for how to: how to create number using query
Olaf Helper
Thursday, September 28, 2017 7:23 AM
HOW TO SELECT THE VALUE OR GENERATE THE VALUE BETWEEN TWO DECIMAL NUMBERS
Thursday, September 28, 2017 7:36 AM
With a recursive CTE
DECLARE @from decimal(15, 2) = 0.98;
DECLARE @to decimal(15, 2) = 1.02;
;WITH cte AS
(SELECT @from AS Value
UNION ALL
SELECT CONVERT(decimal(15, 2), Value + 0.01)
FROM cte
WHERE Value < @to)
SELECT *
FROM cte
Olaf Helper
Thursday, September 28, 2017 7:54 AM
select number*.01 from master..spt_values where number*.01 between .98 and 1.02
Thursday, September 28, 2017 8:49 AM
Hi,
You have already posted two threads before this one about one same question.
Do not post duplicated threads. We have already provided you two kinds of solutions. One is using recursive CTE and one is using loop. If you don't want to use CTE, you can try loop.
Won't the two solutions resolve your requirement? If so, please tell us why.
Thanks,
Xi Jin.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Thursday, September 28, 2017 4:05 PM
Hi,
Hope the below query helps:
declare @a float =0.98 , @b float=01.02 , @i float=0.01
declare @t table (result float)
while (@a <= @b)
begin
insert @t select @a
set @a=@a+@i
end
select * from @t
Thanks & Regards,
Praveena KK.