Friday, October 17 2008: Function
I'll pay 1000 space bucks to anyone who can send me a single-line function that will return the following table of values:
This works, but the IF offends me:
| x | f(x) |
|---|---|
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | 4 |
| 6 | 5 |
| 7 | 6 |
| 1 | 7 |
This works, but the IF offends me:
CREATE FUNCTION dbo.fx ( @x int ) RETURNS int AS BEGIN DECLARE @y int SET @y = @x - 1 IF @y = 0 SET @y = 7 RETURN @y END
fandango wrote: