May 13, 2009 at 10:27 pm
Hi All,
I am having a table named item_data where in item and active_date are two columns.
Another table is Error_log where the columns are item,store,tran_date.
I want to update active_date for only 5 items in item_data table with minimum value of tran_date for that particular item in Error_log table.
One solution i had is get item,min(tran_date) from Error_log table and then manually update the active_date in item_date for each and every item.
I am looking for a query which will do this process in a single shot by looking into the two tables provided the only 5 items.
Can anyone help me in this?
Thanks,
Rupesh.
May 13, 2009 at 10:34 pm
This sounds like a T-SQL question to me - this is the SSIS forum.
It is difficult to answer your question without seeing some sample data. Why only 5 items - what is special about just these items?
May 13, 2009 at 11:07 pm
Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 14, 2009 at 11:33 am
As an example i mentioned as 5 items out of any thing, and nothing special about them, you can take it as count less than the Total number of items.:-)
May 14, 2009 at 1:20 pm
Item_data: item and active_date
Item Active_date
1111 12-Jan-09
2222 15-Mar-09
3333 21-Feb-09
4444 25-Apr-09
5555 14-Feb-09
6666 12-Mar-09
7777 08-Feb-09
8888 29-Apr-09
9999 11-Mar-09
Error_log: item,store and tran_date
Item Store Tran_date
1111 London 21-Apr-09
2222 Newyork 29-Jan-09
3333 Mumbai 11-Jan-09
4444 Chennai 29-Apr-09
5555 Jaipur 16-Mar-09
6666 Kolkata 19-Apr-09
7777 Delhi 05-Jan-09
8888 Bangalore 13-Mar-09
9999 Hyderabad 14-Mar-09
4444 Mumbai 13-Jan-09
2222 Bangalore 15-Feb-09
7777 Kolkata 14-Mar-09
1111 Tirupati 04-Jan-09
6666 Chennai 11-Jan-09
8888 Jaipur 05-May-09
3333 London 30-Mar-09
5555 Malaysia 11-Jan-09
9999 Tokyo 12-Feb-09
Is the data sufficient to answer my question or do anyone need further more explanation..please??
May 14, 2009 at 2:56 pm
Please read through the article I linked. You're still missing the table definition (as a create table) and that sample data's going to be hard to use in it's current form.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 14, 2009 at 5:56 pm
Please also post how you would like the active date to look after the update has been performed. Your post shows the 'before' situation only.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply