I am creating a row number in my query based on ordering of a Date
column.
This is the query used:
SELECT *
FROM
(SELECT
*,
ROW_NUMBER() OVER (ORDER BY datePunch) AS RowNum
FROM
Tempdata
WHERE
datePunch IS NOT NULL) AS LogTable
WHERE
LogTable.RowNum BETWEEN 800
AND (SELECT COUNT(*)
FROM Tempdata
WHERE datePunch IS NOT NULL)
AND datePunch IS NOT NULL
Now I want the row number column but not by ordering the datePunch
column. I just want records as they are inserted in the table with no ordering.
Is it possible to do this?
Note :-
I have created a Utility which syncs Client Database. So Database will be different everytime with no guarantee of Identity Column. I am just mapping the Columns & using them in my Query.