lundi 1 août 2016

complicated price range selecting

Here is current select:

SELECT
  a.tid as rate_tid,
  a.tname as tname,
  b.rate_tid as rate_tid,      
  b.price as price,
  b.pricelimit_to as pricelimit_to,
FROM
  rrv_tarife a,
  rrv_prices b
WHERE
  a.tid = b.tarif_id
  AND b.price != '0'
  AND b.pricelimit_to > '800'
ORDER BY b.price 

I have got this result from first sql select, with a max. price of 800.

rate_id  price  pricelimit_to  name 

17 21  900 A
18 33 1000 B
19 36 1500 C
20 33 1000 D
21 22 1600 E

Now I would like to get the rate with the lowest pricelimit_to, but it should also be filtered in the first select

result should be:

17 21  900 A

Can someone help?

Aucun commentaire:

Enregistrer un commentaire