Give number to rows based on condition

Use the ROW_NUMBER() function.

Related articles:

Efficiently Numbering Rows Based on Specific Conditions: A Comprehensive Guide
Numbering rows in a dataset can be a crucial task for data analysts, as it allows for easier tracking and management of data. However, some datasets might require numbering based on specific conditions, which can be time-consuming and challenging, especially with large datasets. In this comprehensive guide, we will explore different efficient methods for numbering rows based on specific conditions.

Automate Row Numbering with Conditional Logic in Excel: Tips and Tricks
Excel is a great tool for managing large datasets, but sometimes it can be challenging to keep track of all the rows and columns. One way to make this task easier is to automate row numbering using conditional logic.

From Mundane to Mighty: How to Transform Your Table with Conditional Numbering in SQL
If you're working with large datasets in SQL, you've probably spent plenty of time trying to organize and analyze the information. One valuable tool that can save you time and give you more control over your data is conditional numbering. This feature allows you to assign a unique number to each row in a table based on conditions you set. Here's how it works: