countrymeister
asked on
SQL Query Help
I have a table OrderHistory
RegionID
Group
Account
orderDate
CreateDate
CreateUserID
LastUpdatedDate
LastUserID
I need to update this table where the two columns
Group
Account
Where the Group IS NULL
with values from the same table having a non null value for the same RegionID, closest to the OrderDate
Example
Current Rows in the table
1)
00123 - region
CENTRAL - Group
A231 - Account
12/10/2010 - Order date
2)
00123 - region
CENTRAL1 - Group
A2312 - Account
12/15/2010 - Order date
3)
Row to be updated
0123 - Region
NULL - Group
NUll - Account
OrderDate - 12/12/2010
RegionID
Group
Account
orderDate
CreateDate
CreateUserID
LastUpdatedDate
LastUserID
I need to update this table where the two columns
Group
Account
Where the Group IS NULL
with values from the same table having a non null value for the same RegionID, closest to the OrderDate
Example
Current Rows in the table
1)
00123 - region
CENTRAL - Group
A231 - Account
12/10/2010 - Order date
2)
00123 - region
CENTRAL1 - Group
A2312 - Account
12/15/2010 - Order date
3)
Row to be updated
0123 - Region
NULL - Group
NUll - Account
OrderDate - 12/12/2010
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
All, that is a type it should be
3)
Row to be updated
00123 - Region
NULL - Group
NUll - Account
OrderDate - 12/12/2010
3)
Row to be updated
00123 - Region
NULL - Group
NUll - Account
OrderDate - 12/12/2010
ASKER
it is a character column
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is that column an integer or a character column?