mysql - How to add a condition to the result of an SQL query? -


i have table,

date_of_order|quantity 01/01/17     | 1  02/01/17     | 1 04/01/17     | 1 05/01/17     | 1 

i need sum of quantities before 03/01/17, result of sql query include condition date if not in table, this:

03/01/17 2 

i know how show sum:

 select sum(quantity) table_name date_of_order < '2017-01-03' 

but how include date(03/01/2017) result?

thanks!

just add separate column:

select '2017-01-03' datestart, sum(quantity) table_name date_of_order < 2017-01-03 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -