c# - How to insert Serial Number to Unpivoted Column -


i have table in db contains date , time separately in columns time table displaying single 1 in front end had joined date , time column , inserted temporary table , unpivoted it,but pk_id same both unpivoted columns in front end in drop down box when select item in index @ 6 in ddl after postback occur return index 1 in ddl.so,is there way put serial number unpivoted columns, unpivot query is,

  select *   (     select pk_bid,no_of_batches,batch1,batch2,batch3,batch4, #tempbatch    ) p     unpivot(batchname [batches] in([batch1],[batch2],[batch3],[batch4])) unpvt   

in above query pk_bid & no_of_batches same if put rownumber() partition pk_bid order pk_bid or rownumber() partition no_of_batches order no_of_batches gives 1,1 same.

i had solved above problem this,

i had created temporary table , created serial number column in table differant values query had done is,

    create table #tempbatch2    (      pk_bid int,        no_of_batches int,        batchname varchar(max),        [batches] varchar(max)      )      insert #tempbatch2      select *       (         select pk_batchid,no_of_batches,batch1,batch2,batch3,batch4 #tempbatch        ) p      unpivot(batchname [batches] in([batch1],[batch2],[batch3],[batch4])) unpvt    select row_number() over(order (batchaname))     s_no,pk_bid,no_of_batches,batchname,[batches] #tempbatch2  

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -