Skip to content
Advertisement

How to Loop department names

Oracle SQL Developer

I want to Loop department id and department names starting from dep_id = 10 and till 50th department. Departments are increasing by 10, so, there are 5 departments from 10 to 50.

See Departments table here

Here’s my code

And here is the output,

But as you can see the Administration row is repeating itself. The output should be like this

What am I supposed to do about this?

Thanks!

Advertisement

Answer

How about a simple cursor FOR loop?

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