Home > DeveloperSection > Forums > How to count number of rows before an ID in SQL Server
ben reitman
ben reitman

Total Post:96

Points:676
Posted on    February-03-2014 12:52 AM

 C# C# 
Ratings:


 1 Reply(s)
 672  View(s)
Rate this:

I need to count the total number of rows in a table before the certain row ID.

I have this query

select count (ClientID)

FROM [Seek].[dbo].[seekClient]

where ClientID < '12'

which works fine for the case of integer primary key, but I am not sure how to do that in case of GUID ??

Kindly help me in this case.

Thanks



Pravesh Singh

Total Post:411

Points:2881
Posted on    February-03-2014 1:06 AM

Hi Ben,

You should use a different column (not id) that defines what you mean by 'before'. It might be, for example, a 'DateOfCreation', 'creation_date' etc. column.



Don't want to miss updates? Please click the below button!

Follow MindStick