I have a table that shows the start date and the end date for a product. I have the total value and the product name in the table. I would like to be able to show the months and years between the two dates while including the product name and the average of the value over the time period. I have been trying to work with a query that solves the issue for a single product. I need the result to show across multiple products. I'm getting an error saying that I cannot query more than one item in the sub query. Is it possible to get the result I'm looking for? Thank you for your help. Itβs greatly appreciated.
SQL to display both month and year between two dates
Example of Product Data
Product Value Start Date End Date
Widget A 100 1/1/2012 5/1/2013
Widget B 500 2/1/2010 6/1/2012
Desired Results
Product Date Month Year Value
Widget A 1/1/2012 Jan 2012 5.88
Widget A 2/1/2012 Feb 2012 5.88
Widget A 3/1/2012 Mar 2012 5.88
Widget A 4/1/2012 Apr 2012 5.88
Widget A 5/1/2012 May 2012 5.88
Widget A 6/1/2012 Jun 2012 5.88
Widget A 7/1/2012 Jul 2012 5.88
Widget A 8/1/2012 Aug 2012 5.88
Widget A 9/1/2012 Sep 2012 5.88
Widget A 10/1/2012 Oct 2012 5.88
Widget A 11/1/2012 Nov 2012 5.88
Widget A 12/1/2012 Dec 2012 5.88
Widget A 1/1/2013 Jan 2013 5.88
Widget A 2/1/2013 Feb 2013 5.88
Widget A 3/1/2013 Mar 2013 5.88
Widget A 4/1/2013 Apr 2013 5.88
Widget A 5/1/2013 May 2013 5.88
Widget B 2/1/2010 Feb 2010 17.24
Widget B 3/1/2010 Mar 2010 17.24
Widget B 4/1/2010 Apr 2010 17.24
Widget B 5/1/2010 May 2010 17.24
Widget B 6/1/2010 Jun 2010 17.24
Widget B 7/1/2010 Jul 2010 17.24
Widget B 8/1/2010 Aug 2010 17.24
Widget B 9/1/2010 Sep 2010 17.24
Widget B 10/1/2010 Oct 2010 17.24
Widget B 11/1/2010 Nov 2010 17.24
Widget B 12/1/2010 Dec 2010 17.24
Widget B 1/1/2011 Jan 2011 17.24
Widget B 2/1/2011 Feb 2011 17.24
Widget B 3/1/2011 Mar 2011 17.24
Widget B 4/1/2011 Apr 2011 17.24
Widget B 5/1/2011 May 2011 17.24
Widget B 6/1/2011 Jun 2011 17.24
Widget B 7/1/2011 Jul 2011 17.24
Widget B 8/1/2011 Aug 2011 17.24
Widget B 9/1/2011 Sep 2011 17.24
Widget B 10/1/2011 Oct 2011 17.24
Widget B 11/1/2011 Nov 2011 17.24
Widget B 12/1/2011 Dec 2011 17.24
Widget B 1/1/2012 Jan 2012 17.24
Widget B 2/1/2012 Feb 2012 17.24
Widget B 3/1/2012 Mar 2012 17.24
Widget B 4/1/2012 Apr 2012 17.24
Widget B 5/1/2012 May 2012 17.24
Widget B 6/1/2012 Jun 2012 17.24