mysql - Don't return the lowest value if -


the goal

don't return lowest price markets suspended.

the problem

i don't know syntax.

the scenario

there following stored procedure lowest , biggest price of specific product:

begin     select min(case when product.promotionalprice = 0             product.originalprice else             least(product.promotionalprice, product.originalprice)             end) minproductprice,        max(case when product.promotionalprice = 0             product.originalprice else             least(product.promotionalprice, product.originalprice)             end) maxproductprice     products product     product.name = 'playstation 3'; end 

the context is: there markets , products. products belong markets. if market suspended, doesn't display products , nor add them max/min price comparison.

can understand? i want exclude products markets suspended min or max statement of above's query.

the tables

here markets table:

+----+------+-------------+ | id | name | situationid | +----+------+-------------+ | 1  |    | 1           | +----+------+-------------+ | 2  | b    | 2           | +----+------+-------------+ | 3  | c    | 3           | +----+------+-------------+ 

here markets_situations table:

+----+-----------+ | id | name      | +----+-----------+ | 1  | neutral   | +----+-----------+ | 2  | premium   | +----+-----------+ | 3  | suspended | +----+-----------+ 

and finally, here products table:

+----+---------------+--------+------------------+---------------+ | id | name          | market | promotionalprice | originalprice | +----+---------------+--------+------------------+---------------+ | 1  | xbox 360      | 1      | 0                | 225,00        | +----+---------------+--------+------------------+---------------+ | 2  | xbox 360      | 2      | 99,00            | 175,00        | +----+---------------+--------+------------------+---------------+ | 3  | xbox 360      | 3      | 0                | 135,00        | +----+---------------+--------+------------------+---------------+ | 4  | playstation 3 | 1      | 0                | 189,00        | +----+---------------+--------+------------------+---------------+ | 5  | playstation 3 | 2      | 125,00           | 165,00        | +----+---------------+--------+------------------+---------------+ | 6  | playstation 3 | 3      | 110,00           | 185,00        | +----+---------------+--------+------------------+---------------+ 

to enhance comprehension

i don't want display 110,00 min price of stored procedure's result because market (c) suspended.

what did

i tried following, without success:

begin     [...]      product.name = 'playstation 3'     , marketsituation.id <> 3; end 

what happens? and condition nothing. query keeps returning me price of suspended market.

select min(case when product.promotionalprice = 0         product.originalprice else         least(product.promotionalprice, product.originalprice)         end) minproductprice,    max(case when product.promotionalprice = 0         product.originalprice else         least(product.promotionalprice, product.originalprice)         end) maxproductprice products product inner join markets on product.market = markets.id , markets.situationid <> 3 product.name = 'playstation 3'; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -