sql server - SQL Rotating numbers -


I want to make a rotation argument in SQL as if it is believed that 3 numbers are 1,2,3, the first week 1,2 will be selected next 3,1 next 2,3 and so on ..... If 4 numbers are 1,2,3,4 then 1,2 next 3,4 next 1,2 so many .. In this way ... I want to generate numbers in the SQL server. Please help me

You do this:

  declared @cnt int, @ Select ofs int @cnt = count (*) Set TheTable from @ofs = (((@week - 1) * 2)% @cnt) + 1 Select * TheTable where between @ofs and @ofs + 1 union Choose the number of *, from TheTable where choose the number between @ofs - @cnt and @ofs - @cnt + 1  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -