This is a SQL question, not a Toad question, but: LEAD and LAG are your friends; make their acquaintance. You can do something like this:
(Need the NVL because last_date will be null if the most recent update for a product is more than 3 years ago)
US Row Crops IT Data Management Team
800 N. Lindbergh Blvd. G3WB - Saint Louis, MO - 63167
From: mark1906 [mailto:firstname.lastname@example.org]
Sent: Monday, March 17, 2014 1:06 PM
Subject: [Toad for Oracle - Discussion Forum] Need query to look at cost changes for past 3 years
Need query to look at cost changes for past 3 years
Thread created by mark1906
I’m working in TOAD for Oracle. I have an Acquistions_Cost table. I have to find the change of cost for the last three years. It has four(4) colunms: Item_no, Update_date, Cost and Active_flag.
This table contants about 1.5 million rows of SKU items. The active_flag has two options (A-Active and I-Inactive). Active means that is the current cost which can be tracked by the Update_date. Some items update every year and some maybe every two to 5, so
I can’t just do a minus three years on the Update_date. I need a way to look at data and get the cost change for last three years. Remember, some may not have changed in 6. This data goes back to 1999. I have aggregated my sales data in another table by calendar
To reply, please reply-all to this email.
Stop receiving emails on this subject.
Unsubscribe from Toad for Oracle - General notifications altogether.
Toad for Oracle - Discussion Forum
this post as spam/abuse.
This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled
to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and
all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its
subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of “Viruses” or other “Malware”.
Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying
this e-mail or any attachment.
The information contained in this email may be subject to the export control laws and regulations of the United States, potentially
including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of
Treasury, Office of Foreign Asset Controls (OFAC). As a recipient of this information you are obligated to comply with all
applicable U.S. export laws and regulations.