Advertisement
oquidave

empty dates

May 13th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. date | sum
  2. ------------+-------
  3. 2011-04-29 | 34350
  4. 2011-04-28 | 34650
  5. 2011-04-27 | 34050
  6. 2011-04-26 | 35550
  7. 2011-04-25 | 34800
  8. 2011-04-23 | 36750
  9. 2011-04-22 | 37800
  10. 2011-04-21 | 35550
  11. 2011-04-20 | 35850
  12. 2011-04-17 | 34050
  13. 2011-04-16 | 36150
  14. 2011-04-13 | 36450
  15. 2011-04-11 | 32100
  16. 2011-04-10 | 36600
  17. 2011-04-09 | 41400
  18. 2011-04-06 | 38100
  19. 2011-04-05 | 35250
  20. 2011-04-04 | 35400
  21. 2011-04-03 | 36150
  22. 2011-04-02 | 36000
  23. 2011-04-01 | 0
  24. 2011-03-31 | 36300
  25. 2011-03-30 | 36300
  26. 2011-03-25 | 37200
  27.  
  28. //query
  29.  
  30. select date(t_stamp), sum(total_charge) from mt.mt_batches where complete='t' and keyword='pablo'and date(t_stamp) between '2011-01-01' and '2011-04-30' group by date(t_stamp) order by date(t_stamp) desc;
  31.  
  32. //question
  33. i want 0 value entered for the dates that are not there.
  34. like this
  35. date | sum
  36. ------------+-------
  37. 2011-04-30 | 0 (not present, has no value)
  38. 2011-04-29 | 34350
  39. 2011-04-28 | 34650
  40. 2011-04-27 | 34050
  41. 2011-04-26 | 35550
  42. 2011-04-25 | 34800
  43. 2011-04-23 | 36750
  44. 2011-04-22 | 37800
  45. 2011-04-21 | 35550
  46. 2011-04-20 | 35850
  47. 2011-04-19 | 0(not present, has no value)
  48. 2011-04-18 | 0(not present, has no value)
  49. 2011-04-17 | 34050
  50. 2011-04-16 | 36150
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement