Reputation: 17
I have 1 table where is 2 columns that i need to use at this moment( length and length_to_fault). If length has a null(N/A) value then i need to select value from length_to_fault and opposite. I also need to sort everything and i can do it with 1 column like this:
select d.* from (select d.*, lead(length::float) over (partition by port_nbr, pair order by add_date) as next_length from diags d where length != 'N/A') d
this select sorts everything except length_to_fault. If 1 record has value in length_to_fault , it will be ignored and it wont show up. Is there any suggestions? Maybe its possible to just make these 2 columns into 1? It sounds much logical. But how?
Upvotes: 0
Views: 73
Reputation: 17
I changed it to select d.* from (select d.*, lead(sum(length::float + length_to_fault::float)) over (partition by port_nbr, pair order by d.add_date) as next_length from diags d)d
i get error : column "d.ip" must appear in the group by clause or be used in an aggregate function.
I dont need to use ip column... I even dont know where to put that ip right now
Upvotes: 1