SQL行计数器

时间:2016-10-17 23:35:58

标签: sql-server

我需要根据匹配字段的数量返回一个值。

当前输出

public static String insertSpaceBetweenSymbolAndValue(String s)
{
    int index = 0;
    while (index < s.length() && !Character.isDigit(s.charAt(index)))
        index++;
    return (index != s.length()) ? s.substring(0, index) + " " + s.substring(index) : s;
}

期望输出

Job   |  Image
A1234 |  FileA
A1234 |  FileB
A1235 |  FileA
A1236 |  FileA
A1236 |  FileB
A1236 |  FileC

1 个答案:

答案 0 :(得分:1)

Select Job
      ,Image
      ,Order = Row_Number() over (Partition By Job Order By Image)
 From YourTable