This covers most bases.
SELECT
CODE,
ROW_NUMBER() OVER (PARTITION BY CODE ORDER BY NAME) - 1 As C_NO,
NAME
FROM
MyTable
More Related Contents:
- Equivalent of Oracle’s RowID in SQL Server
- How do I use ROW_NUMBER()?
- How do I get a SQL row_number equivalent for a Spark RDD?
- Oracle ‘Partition By’ and ‘Row_Number’ keyword
- Sql Mathematical calculations [closed]
- I need help formatting inner join command in SQL query
- Search All Fields In All Tables For A Specific Value (Oracle)
- How to deal with SQL column names that look like SQL keywords?
- Generating a range of numbers in MySQL
- How to get next/previous record in MySQL?
- SQL best practice to deal with default sort order
- SQL transpose full table
- How to Create a real one-to-one relationship in SQL Server
- How does GROUP BY work?
- Linq version of SQL “IN” statement
- mysql, iterate through column names
- mySQL Returning the top 5 of each category
- Dynamic SQL to generate column names?
- Normalization in plain English
- postgresql generate sequence with no gap
- SQL Server PIVOT perhaps?
- Core Data Performance with Single Parent Entity
- How to find consecutive rows based on the value of a column?
- Custom aggregate function (concat) in SQL Server
- Find last day of a month in Hive
- Which SQL query is faster? Filter on Join criteria or Where clause?
- SQL Server *= Operator?
- Slow bulk insert for table with many indexes
- Convert date to YYYYMM format
- Oracle Date TO_CHAR(‘Month DD, YYYY’) has extra spaces in it