473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Complicated date selection

2
I have a table that has part numbers with affectivity dates like so
Part 1 01/01/2003
Part 2 07/15/2004
Part 1 09/30/2005
Part 2 11/26/2006
Part 1 12/15/2007

I need to find all the Parts sales for each part between the first effectively date and the next effectively date and then the sales between the second effectively date and the third date and then between the third date and that date plus 36 months. The last date in the table always has an end date of 36 months from that date while previous dates have and end date of the next date in the table for that part.

Any suggestions?
Feb 9 '12 #1
5 1458
ck9663
2,878 Expert 2GB
Say what?...Just kidding, I got confused...

Can you post how do you want your output to look like based on the sample data you posted?


~~~ CK
Feb 9 '12 #2
Newface
16
just i was try to understand your issue and as per my perception

Expand|Select|Wrap|Line Numbers
  1. select partno,sum(sales) sale from test where date >'2003-01-01' and date<'2006-01-01' group by partno
  2.  
might help you in some manner
Feb 9 '12 #3
jdc73
2
Sorry, looks like I did not give enough info.
I have two tables, one with all the sales information including the date the sale was made. The other table contains the part revision information. This table lists the part number which was revised and the date of the revision. Each part can be revised any number of times during its life cycle. I need to produce a report of all the sales for each part that has been revised for periods starting with the first revision date to the next revision date and then from that revision date to the next and so on. Each revision has a life cycle of 36 months unless it is revised within that time period. The output should look something like this:
Part Number Beginning Date Ending Date Sales Amount
Xxxxx1 01/01/2007 05/15/2008 $000,000
Xxxxx2 01/25/2009 02/20/2010 $000,000
Xxxxx1 05/15/2008 09/30/2011 $000,000

If you need more info, let me know.
Thanks
Feb 10 '12 #4
Newface
16
if i understood,this should be :
Expand|Select|Wrap|Line Numbers
  1. select t1.PartNumber,t1.BeginningDate,t1.EndingDate,sum(t.sales) Sales
  2.        from test1 t1 inner join test t 
  3.        on t1.PartNumber=t.PartNo
  4.        group by t1.PartNumber,t1.BeginningDate,t1.EndingDate
  5.  
  6.  
Feb 10 '12 #5
Subject promises to be interesting , perhaps the stock chips :)
Feb 11 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jorntk | last post by:
How can i create a date drop menu that automatically have today's date selected?
0
by: Dalan | last post by:
Maybe this isn't as difficult as it seems, but cannot get it to work correctly. I have an Access 97 Form which contains 12 separate rows of text boxes that are used for entering monthly sales...
1
by: DD | last post by:
I have a mainform with a subform. The main form as a dropdown box "chooseDate", in the afterupdate event i requery the subform so all records with the same date are viewed. Now i only want to...
26
by: jshanman | last post by:
I am writing a timeline that uses Google Maps. I have a function that converts a date time to latitude coords. This function is used to draw the markers on the timeline. I need a reverse function...
3
by: campbell.mcneill | last post by:
Hi, I'm trying to parse the following date "Wed, 18 Dec 2002 08:01:23 +0100 (MET)". I'm using the following code: System.IFormatProvider format = new...
1
by: sang | last post by:
Hi I am working in mysql database system, i want to select the some fields with the date. For Example in a company employers details are stroed the is name, dateofjoin, age, Address etc. I want...
1
by: mrityunjay11 | last post by:
i want a date selection form in jsp and that variable should be caught in servlet that is how to catch date varible in my servlet. thanks a lot Regards mrityunjay singh
0
by: AboutJAV | last post by:
Hi, I am using a DateTimePicker control to allow the user to select a new date. At first, I use an event Date_Changed Event as well as databinding the control to a property. When the user click...
4
by: shivasusan | last post by:
Hi! Pls help me.... i don't know to do. first row : 22.2.2009 to 28.2.2009 second row: 3.3.2009 to 15.3.2009 third row: 10.3.2009 to 30.3.2009 // here i want to display alert...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.