SQL command to calculate from Amount and ID, total weight -


table: orderproducts

orderid   quantity       weight ----------------------------------- 4           5             0.1 4           2             0.5 5           3             2.5 5           7             0.9 

1) following sql command, total weight calculated correctly, product quantity ignored. how can expand sql command query quantity of product?

select orderid, sum (weight) totalweight orderproducts group orderid 

now have orderid 4 value (totalweight) => 0.6

must correctly => 1.5

2) in addition, sql command "where" (where other_table.status = "finish") extend table. not work. :-(

select orderid, sum (weight) totalweight orderproducts other_table.status = "finish" group orderid 

query:

select orderid,        sum(weight*quantity) totalweight orderproducts join othertable b on (b.orderid=b=id) b.status = "finish" group orderid 

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 -