MYSQL Query using SUM -


how can make select 7500 or greater on_hand value column?

" list part number part descrtiption , onhand value each part on hand value @ least $7,500. assign on_hand_values computed column."

this have far, tried subquerys in statements cant figure out.

select part_num, description, sum(on_hand * price) on_hand_value part sum(on_hand * price)'7500' group part_num, description; 

part table

part_num    description     on_hand     class   warehouse   price  at94       iron               50         hw         3       24.95 bv06       home gym           45         sg         2       794.95 cd52       microwave oven     32        ap          1       165.00 dl71       cordless drill     21        hw          3       129.95 dr93       gas range           8        ap          2       495.00 dw11       washer             12        ap          3       399.99 fd21       stand mixer        22        hw          3       159.95 kl62       dryer              12        ap          1       349.95 kt03       dishwasher          8        ap          3       595.00 kv29       treadmill           9        sg          2       1390.00 

you can't use where, have use having aggregate functions:

select part_num, description, sum(on_hand * price) on_hand_value part group part_num, description; having sum(on_hand * price)'7500' 

where evaluated before grouping , summing happens, having evaluates on result set, after records filtered , grouped


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -