0

Possible Duplicate:
MySQL how to fill missing dates in range?

I have table with name "trip_data".There it is having four fields

|trip_paramid|fuel_content|creation_time|vehicle_id

I want to generate a report so that input parameters will be FromDate and ToDate.So output should contain all the date in between From and to date(creation_time) also corresponding Maximum fuel_content for each date.If corresponding fuel_content is not there for a date,then fuel_content should be displayed as "NIL".How can i write a query for this in MySQL.So i need a query to display all dates in between two date range even if there is no corresponding data for that."Following is the sample schema and data for this table. http://sqlfiddle.com/#!2/d6d207

Community
  • 1
  • 1
vmb
  • 2,878
  • 15
  • 60
  • 90
  • Stackoverflow is not a "do my work for me" site! Have a serious try, when you're stuck, come back and ask. Then we will be glad to help. Also your question is not that trivial. Tip: An easy solution would be to create a table which simply contains dates. Good luck. – fancyPants Dec 08 '12 at 19:47
  • Also it's not clear what you mean with "report", "dailywise". – fancyPants Dec 08 '12 at 19:49
  • actually i need this query for using it in a reporting tool.even i described it in detail ,main thread for this question is "how to display all dates in between two date range even if there is no correesponding data for that".every two minutes i getting packets and inseting to this table.but in certain days it will not insert to db. – vmb Dec 09 '12 at 03:59
  • @vmb I understood that already, that's why I gave you the tip with the dates table. – fancyPants Dec 09 '12 at 08:05
  • @tombom..its not a proper way.for every month,number of days is different. – vmb Dec 09 '12 at 08:58
  • if it is year,ur solution have some significance.but here it is not the case.we need to get all dates between a range.it will vary depending on month .. – vmb Dec 09 '12 at 09:07

0 Answers0