2 years ago
#147374
Harald B.
Select with "default" value and specific overwrite value
maybe a silly question ..
i would have to like one SQL table containing rows which should be used as default, and then rows for specific values ..
example table A:
ID; Filter; Class; Value
1 ; % ; Car ; 100 kg
2 ; % ; Bus ; 500 kg
3 ; my ; Car ; 600 kg
table B:
Query;
my;
yours;
i know i can have both values for car by creating a view and joining the Filter IN ..
SELECT
A.Class, A.Filter, B.Query, A.Value
FROM B
INNER JOIN A ON A.Filter in (B.Query, '%')
this would return
CAR, %, yours, 100 kg
CAR, my, my, 600 kg
BUS, %, yours, 500 Kg
My problem. if i get back 2 rows (default % and CAR) i ONLY want to have the specific row with "my" and not the default with "%"
so this i expect as result :
CAR, my, my, 600 kg
BUS, %, yours, 500 KG
same if there would be more specific Overwrites for BUS, CAR, ..
Any suggestion how to solve this in SQL only ?
sql
select
sql-view
0 Answers
Your Answer