Hi
I have below data and i want to display Row Numbers. using Sql Query
| Row Number | G/l Account | Debit | Credit |
| 1 | 3001 | 0 | 0 |
| 2 | 3001 | 0 | 0 |
| 3 | 3001 | 0 | 0 |
| 4 | 3001 | 0 | 0 |
| 5 | 3001 | 0 | 0 |
| 6 | 3001 | 0 | 0 |
| 7 | 3001 | 650.16 | 0 |
| 8 | 3001 | 31,860.00 | 0 |
| 9 | 3001 | 0 | 100 |
| 1 | 3002 | 100 | 0 |
| 2 | 3002 | 200.00 | 0 |
| 3 | 3002 | 0 | 50 |
Thanks
Muhammad Imran AnsariPosted Mar 26, 2025, 10:24 AM
Hello Ramco,
To display Row Numbers that reset for each G/L Account, use the
ROW_NUMBER()function withPARTITION BY.Good Luck!
Emily FosterPosted Mar 26, 2025, 8:18 AM
Hi! To display row numbers in SQL, you can use the ROW_NUMBER() function. This function assigns a unique sequential integer to each row within a partition of a result set.
Here is an example SQL query that demonstrates how to display row numbers based on your provided data:
Replace `YourTableName` with the actual name of your table where this data is stored. By using the `ROW_NUMBER() OVER (ORDER BY [G/l Account])` clause, you assign row numbers based on the order of the G/l Account.
This query will generate row numbers for each row in the result set, allowing you to uniquely identify each row. Let me know if you need further assistance or have any other questions!