Select COUNT > 10K in C# and SQL

Asked

Viewed 63 times

-2

I would like to select in records greater than 10 thousand and delete after.

select count (FuncionarioID) > 10000 FROM FuncionarioLog;

How should I select correctly?

1 answer

0


You can always do it this way:

SELECT  *
FROM    (
            SELECT  *
                ,   ROW_NUMBER() OVER(ORDER BY Registo ASC) AS Linha
            FROM    Tabela) X
WHERE   Linha <= 10000

In the ORDER BY Registo ASC we must replace the Registo by the column by which we want to sort, that is, the one by which the records will be ordered in order to generate the row number (ROW_NUMBER).

Instead of Tabela we will obviously have to put the name of our table.


More information on the use of ROW_NUMBER in the Microsoft documentation: ROW_NUMBER (Transact-SQL)

  • Show!! Helped. Hugs

  • Perfect :)! Take the opportunity to give an UP on the answer?

Browser other questions tagged

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