Skip to content
Advertisement

UNION ALL not combining rows

I have this table called “valores_indices” where it imports stocks values every 1 hour, I need to get the values from each monitored stock at 8am and 6pm, those being respectively my “vlrAberto” and “vlrFechado” selects I don’t get why these are not merging, I’ve done it before, any help would be appreciated since I’m running out of ideas, I’ve tried to nest it without any luck

EDIT

This is what I get

enter image description here

This is the expected result

enter image description here

Advertisement

Answer

I think that you want conditional aggregation here:

Another option is a lateral join:

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