sql - Joining Tables: Only (!) add missing rows -
i want join following tables (records
, tip
). goal missing war
rows (dependend on id
) added. example see war = 2
missing id = 80
.
note: war
smaller or equal value of tip. value of value
should null
in added rows. table in bottom goal.
i not sure how solve problem. condition results of records."tip" >= tip."tip"
.
i use hana database.
thank in advance. best regards.
this how works (sorry these tips little bit confusing):
select a."id", b."tip" "war", c."val" ( select distinct "id", max("tip") "max" records t group "id" ) inner join tip b on 1=1 left join t0 c on a."id" = c."id" , b."tip" = c."war" b."tip" <= a."max" order a."id", b."tip"
Comments
Post a Comment