Ho una query che restituisce:
RowNumber Name
===================================
1 Invoice-02116 (1).pdf
1 Invoice-02116 (2).pdf
1 Invoice-02116.pdf
2 Invoice-02116.pdf
3 Invoice-02116.pdf
4 Invoice-02116.pdf
5 Invoice-02116.pdf
Ciò di cui ho bisogno è qualcosa del tipo:
RowNumber Name
===================================
1 Invoice-02116 (1).pdf
2 Invoice-02116 (2).pdf
3 Invoice-02116.pdf
3 Invoice-02116.pdf
3 Invoice-02116.pdf
3 Invoice-02116.pdf
3 Invoice-02116.pdf
Più esattamente, per visualizzare il grado in base alla colonna del nome.
Quello che sto usando per la colonna RowNumber è:
SELECT ROW_NUMBER() OVER (PARTITION BY ff.Name ORDER BY ff.Name) AS RowNumber, ff.Name
risposte:
3 per risposta № 1Uso DENSE_RANK
anziché :
SELECT DENSE_RANK() OVER (ORDER BY ff.Name) AS RowNumber...
2 per risposta № 2
Uso DENSE_RANK
con un ordine appropriato:
SELECT
DENSE_RANK() OVER (ORDER BY LEN(Name) DESC, Name) AS RowNumber,
Name
FROM yourTable;