Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Compare Price change

Author  Topic 

Morris
Starting Member

3 Posts

Posted - 2011-09-14 : 14:43:11
I have been able to Compare when a price changes in the results and place the string 'Research' in a new column next to the price change.
Now the client would like to have the term 'Research' to repeat for the rest of the results or until it changes again.

I believe this may be solved by joining the table to itself but that logic seems to escape me. Any assistance would be helpful, Thank you.

CURRENT
IPK Price Action
1 169.99 NULL
2 169.99 NULL
3 169.99 NULL
4 169.99 NULL
5 159.99 Research
6 159.99 NULL
7 159.99 NULL
8 159.99 NULL
9 159.99 NULL


Desired
IPK Price Action
1 169.99 NULL
2 169.99 NULL
3 169.99 NULL
4 169.99 NULL
5 159.99 Research
6 159.99 Research
7 159.99 Research
8 159.99 Research
9 159.99 Research

memorykills
Starting Member

18 Posts

Posted - 2011-09-14 : 14:47:44
" to have the term 'Research' to repeat for the rest of the results or until it changes again" ??

if it changes again, what will be displayed in the column?
Go to Top of Page

Morris
Starting Member

3 Posts

Posted - 2011-09-14 : 15:46:12
Looking for Research to repeat for a week after it has changed again.

I can work out some of the dates mainly I am having issues comparing records.

IPK DATE Price Action
1 1/1/2011 169.99 NULL
2 1/2/2011 169.99 NULL
3 1/3/2011 169.99 NULL
4 1/4/2011 169.99 NULL
5 1/5/2011 159.99 Research
6 1/6/2011 159.99 Research
7 1/7/2011 159.99 Research
8 1/8/2011 159.99 Research
9 1/9/2011 169.99 Research
10 1/10/2011 169.99 Research
Go to Top of Page

Morris
Starting Member

3 Posts

Posted - 2011-09-14 : 16:56:17
I joined the table to itself off of DATE and in the join conditions used >= on the DATE Join.

This seemed to get a running total of Research for me. Although its working I'm still working through why? I have a good handle on all kinds of joins and logic in SQL. For some reason joining a table to itself seems to make my mind go sideways. Anyone know of a simple and good resource for learning when and why you would do this?
Go to Top of Page
   

- Advertisement -