This will give a result between 0 and n – 1 for both positive and negative values of x:
((x % n) + n) % n
More Related Contents:
- SQL where clause odd behavior [closed]
- to select all the employees who have joined most recently under king
- How do I escape a single quote in SQL Server?
- Simple way to transpose columns and rows in SQL?
- Count work days between two dates
- Only inserting a row if it’s not already there
- Unpivot with column name
- Selecting data from two different servers in SQL Server
- Maximum size for a SQL Server Query? IN clause? Is there a Better Approach [duplicate]
- SQL JOIN vs IN performance?
- Most efficient way in SQL Server to get date from date+time?
- Convert varchar into datetime in SQL Server
- TSQL Pivot without aggregate function
- How to generate a range of dates in SQL Server
- SQL RANK() versus ROW_NUMBER()
- How to rewrite IS DISTINCT FROM and IS NOT DISTINCT FROM in SQL Server 20008R2?
- How do I delete from multiple tables using INNER JOIN in SQL server
- SQL : BETWEEN vs =
- Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql statement
- How do I perform a GROUP BY on an aliased column in SQL Server?
- How do I make a composite key with SQL Server Management Studio?
- How to get N rows starting from row M from sorted table in T-SQL
- TransactSQL to run another TransactSQL script
- How to Concatenate Numbers and Strings to Format Numbers in T-SQL?
- How can I generate a temporary table filled with dates in SQL Server 2000?
- How can I group time by hour or by 10 minutes?
- Is SQL or even TSQL Turing Complete?
- Getting Dates between a range of dates
- Repeat Rows N Times According to Column Value
- When to use EXCEPT as opposed to NOT EXISTS in Transact SQL?