Skip to content
Advertisement

Serial number auto generation

Facing issue in auto generation of serial number.

How can i use row_number() in proper manner or is there any alternative to achieve the expected results?

Note: I want to write query without using CASE.

Current Results:

Expected Results:

Advertisement

Answer

You can try to use ROW_NUMBER window function in a subquery, then use DENSE_RANK window function to create no column with CASE WHEN expression get rn = 1 row.

sqlfiddle

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement