Sort by position of edited record (sql server)

Asked

Viewed 126 times

0

When I enter a new record, I make an ordination where I sort by the last entered record.

SELECT TOP(50) * FROM TB_CLIENTE_FORNECEDOR where status <> 'S' order by IDCLIENTEFORNECEDOR desc

If I am editing a record of whose id is 10, I want to sort by this id.

1 answer

0

Specify the value of ID as part of your inquiry, and use the Less than or Equal to (<=):

SELECT TOP(50) * 
FROM   tb_cliente_fornecedor 
WHERE  status <> 'S' 
  AND  idclientefornecedor <= 10
ORDER  BY idclientefornecedor DESC 

Reference:

https://msdn.microsoft.com/en-us/library/ms174978.aspx

Browser other questions tagged

You are not signed in. Login or sign up in order to post.