I am using a sql statement in Postgresql. Inside my statment is a case expression. How can I skip a row if case statement is not acceptet
Code:
SELECT *
FROM (SELECT a.link_id AS LinkID,
CASE
WHEN a.From_Ref_Speed_Limit is null and a.To_Ref_Speed_Limit is not null THEN a.To_Ref_Speed_Limit
WHEN a.From_Ref_Speed_Limit is not null and a.To_Ref_Speed_Limit is null THEN a.From_Ref_Speed_Limit
WHEN a.From_Ref_Speed_Limit < a.To_Ref_Speed_Limit THEN a.To_Ref_Speed_Limit
WHEN a.From_Ref_Speed_Limit > a.To_Ref_Speed_Limit THEN a.From_Ref_Speed_Limit
WHEN a.From_Ref_Speed_Limit = a.To_Ref_Speed_Limit THEN a.To_Ref_Speed_Limit
ELSE 0 --unknown
END as SpeedLimit,...
If no condition inside my case statement is guilty it should skip the row and select the next one. Like in case else it should not return NULL it should skip the row and should be go on with the next one. How can I realize this?
WHERE SpeedLimit <> 0in the outer query to filter out unwanted rows. - Giorgos Betsoscalc1, if cond1(calc1) skip row else calc2, if cond2(calc2) skip row, else calc3 and return calc1,calc2,calc3. Doing this without multiple nested queries should be interesting. Anyone? On a different DB is this possible? - Dan Getz