How to Increment values dynamically in SQL select statement -
i want display values a-z , these values auto increment in select statemnet
my output should this
desk desk b desk c .... .... desk z
i stuck here
desk no = (select 'desk'+'')
thanks in advance.
you this, assuming mean tsql and assuming have table you're selecting. if want independently, want make numbers table.
select 'desk ' + char(65 + (((row_number() over(order [somecolumn])) - 1) % 26)) tablename
of course, becomes million times easier if table has id
column has identity
set.
select 'desk ' + char(65 + ((id - 1) % 26)) tablename
on other hand, if have numbers table, that's easier.
select 'desk ' + char(65 + (value % 26)) numbers
Comments
Post a Comment