I have a table which has product quantity column and the database has multiple entries in a single month. For eg: Date is in string format as i have used JXDatePicker so i was unable to store date in Date type in mySql . Date format is (yyyy-MM-dd) 2013-03-01 > 1200 (This is product quantity) 2013-03-05 >200
2013-04-05 > 500 2013-04-10 > 1000
2013-05-05 > 850 2013-05-10 > 50
so i want data as
for March(2013-03-01 to 2013-03-31) > SUM OF product i.e : 1400. April (2013-04-01 to 2013-04-30) > SUM OF product i.e : 1500. May (2013-05-01 to 2013-05-31) > SUM OF product i.e : 900.
also i have different kind of propducts so i will be getting it according to product , For example purpose consider this records are ONLY FOR Product 'A' of Customer 'XYZ', So please consider this in where clause.
I have tried getting the data month wise using query as follows:
select * from mm_inward Where inward_customerId=1 AND inward_productId=1 ORDER BY FROM_UNIXTIME(inward_dateofdc) ASC
and i get the data as follows
the date format have changed because I have pasted it from Excel but please keep the date format as mentioned above.
This is the actual data from my database where i have 2 entries of March 3/2/2013 > 1500 & 3/14/2013 > 120 so i want the sum of it and not differently displaying both the records.
Of course, you could just substring your date string to get the month, but frankly I think you should suffer a little inconvenience for not storing your date values properly in the first place. If you store dates as strings then you prevent anybody else from doing useful date arithmetic on them easily via SQL, as they always have to convert your strings to a proper date first. This is inefficient and unnecessary. Store dates as dates.