-2

I have a table with columns Name and unit.

A customer may have multiple unit. I want to set sl no dynamically in sql like below image.

enter image description here

How can I do this?

user2864740
  • 60,010
  • 15
  • 145
  • 220
Sanjay Sharma
  • 43
  • 2
  • 8

1 Answers1

1

Try this query

select ROW_NUMBER() OVER (Partition By name Order by unit) as sl,
name,Unit
from tablename
Mukesh Kalgude
  • 4,814
  • 2
  • 17
  • 32
  • 3
    For the sake of quality of SO, I believe we shouldn't provide answers for such basic questions which also does not show any efforts towards solving it. – Raging Bull Jul 20 '15 at 07:36
  • @RagingBull Yes you are right but all user should not understand some function – Mukesh Kalgude Jul 20 '15 at 07:37
  • You can just close this question as duplicate. @RagingBull – Felix Pamittan Jul 20 '15 at 07:39
  • 2
    @MukeshKalgude: That is why I gave him an hint as a comment under his question. Spoon feeding won't do anything good in his career. Let him find the solution by himself. We can guide him towards answer. BTW, it wasn't me who downvoted your answer (just some guy who cares the quality of SO). Didn't upvote either. – Raging Bull Jul 20 '15 at 07:39