vendredi 8 mai 2015

Select specific row based on one field vs a default

I am looking to do something I'm not even sure is possible, say I have the following table

ID Part   Setting   Shop
1  A      1    
2  B      2
3  B      1.5       B
4  C      3
5  D      4

I am trying to find a query that will allow me to select all unique part type settings, but if I pass in a shop I will get the specific part for that shop.

So default would be

ID Part   Setting   Shop
1  A      1    
2  B      2
4  C      3
5  D      4

But if I send in WHERE SHOP = B then the result would look like

ID Part   Setting   Shop
1  A      1    
3  B      1.5       B
4  C      3
5  D      4

Aucun commentaire:

Enregistrer un commentaire