Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Inline table-valued function to list numbers

$
0
0
Hi everyone,I'm a newbie and recently I've come across an excercise quite complex (for me). In short, these are the requirements:A - an inline table-valued function with 1 parameter (an INT);B - the output will be 2 columns;C - the first column lists integers in ascending order starting from 1 up to the parameter value (included);D - the second column is a varchar and tests if the number in the first column is divisible by 3, by 5 or by both.I'm stuck on the point C because with an inline table-valued function I cannot use any branching logic (while, if...), then I really don't know how to list the numbers from 1 to the parameter. The point D should be feasible with the CASE expression, but with the point C I'm going slightly mad... Maybe the solution is very easy, but so far I cannot find it out.Any hints?

Viewing all articles
Browse latest Browse all 3145

Trending Articles