contact Posted August 28, 2007 Share Posted August 28, 2007 I have a list of student exam points and i wanna order them by using temporary table. Simply i use this code to do: insert into sm_temp select ' ' as id, sno from deneme order by puan desc The select statement works well if it's alone. But when i wanna use with INSERT, there's no error, but the order is wrong. For ex. the biggest point may gey number 1, the second may get 8, and the 3rd may get 59... How can i solve it? (It works well in Delphi with MSSQL.) Quote Link to comment Share on other sites More sharing options...
fenway Posted August 28, 2007 Share Posted August 28, 2007 I don't see why you're doing this at all... and what do you "care" what ID each record gets? Quote Link to comment Share on other sites More sharing options...
contact Posted August 29, 2007 Author Share Posted August 29, 2007 I don't see why you're doing this at all... and what do you "care" what ID each record gets? I have thousands of records of an exam results for each student. I must give them an queue value. (And of course the highest point will get number 1, the second point will get number 2, etc.) The temp table has 2 fields: id: auto_increment, integer and primary sno: integer I wanna select the id as blank and sno from table "deneme" and wanna add them on the order of puan (desc). After adding all records to temp in order, i will update the all records' queue to temp's id by using temp's sno. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 29, 2007 Share Posted August 29, 2007 I gess you could use a user variable and increment it that way.... Quote Link to comment Share on other sites More sharing options...
Illusion Posted August 30, 2007 Share Posted August 30, 2007 ..............order by NULL,puan desc; Quote Link to comment Share on other sites More sharing options...
fenway Posted August 30, 2007 Share Posted August 30, 2007 ..............order by NULL,puan desc; ???? Quote Link to comment Share on other sites More sharing options...
contact Posted September 2, 2007 Author Share Posted September 2, 2007 Problem continues... Quote Link to comment Share on other sites More sharing options...
fenway Posted September 4, 2007 Share Posted September 4, 2007 Problem continues... Did you try using a user variable to keep a counter as previously suggested? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.