php - How to add multiple limits in mysql query? -


i want select sum of last 200,100 , 50 rows of close price table in single query. given below query 200 rows.

select sum(close_price) tot200 cash_data order date_added limit 0,200  

can me this.

you can use sub queries -

select  (select sum(close_price) cash_data order date_added limit 0,200) tot200,  (select sum(close_price) cash_data order date_added limit 0,100)  tot100, (select sum(close_price) cash_data order date_added limit 0,50)  tot50 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -