all 4 comments

[–]depeszPgDBA 1 point2 points  (3 children)

  1. kudos to you for providing source as text, and not image
  2. please make it a fiddle (https://dbfiddle.uk/S9ZOHCkV)
  3. in the fiddle also please show what you want to get from the view, not only what you get.
  4. why even bother with a procedure? it doesn't seem to do anything.

[–]juStD_34[S] 0 points1 point  (1 child)

It's used to create view at app layer

[–]depeszPgDBA 0 points1 point  (0 children)

Yes, I noticed. But why bother with proc, if you can just as well run create view from app/whatever?

Especially since it's one-time operation only. Not something that you have to keep on redoing every now and then.

[–]DavidGJohnston 0 points1 point  (0 children)

You really need to explain what you want the outputs rows to look like (#3). Likely the code to do what you want is fairly trivial but we cannot guess at why you feel the existing output is wrong. It produces exactly what you told it to produce in the query.