Folks
I have an access database to convert to convert into SQL 2000, Most of the queries are fine to convert as they are select type queries and easy to follow. There are some which are more difficult such as the following problem.
I have this table called TblCombine
Sample data
Ldg , Bnk , Combine , Dupe,
BQ 55.23 BQ55.23 0
BQ 65.23 BQ65.23 0
BQ 75.23 BQ75.23 0
BQ 85.23 BQ85.23 0
BQ 85.23 BQ85.23 0
BQ 85.23 BQ85.23 0
Int 95.23 Int95.23 0
Int 105.23 Int105.23 0
Int 95.23 Int95.23 0
Int 95.23 Int95.23 0
I join the Ldg and Bnk fields into the Combine field.
My problem is I need a process to Order the Combine field.
Then loop through the combine field and if it's not equal to the combine field above it the Dupe field is set to 1, if it is equal the field above it I set to 2 and so on,
Expected Result
Ldg , Bnk , Combine , Dupe,
BQ 55.23 BQ55.23 1
BQ 65.23 BQ65.23 1
BQ 75.23 BQ75.23 1
BQ 85.23 BQ85.23 1
BQ 85.23 BQ85.23 2
BQ 85.23 BQ85.23 3
Int 95.23 Int95.23 1
Int 105.23 Int105.23 1
Int 95.23 Int95.23 1
Int 95.23 Int95.23 2
I have done this in VB where in access as I can follow the process but I am lost at the moment in SQL.
Regards & Thanks
Pator
I have an access database to convert to convert into SQL 2000, Most of the queries are fine to convert as they are select type queries and easy to follow. There are some which are more difficult such as the following problem.
I have this table called TblCombine
Sample data
Ldg , Bnk , Combine , Dupe,
BQ 55.23 BQ55.23 0
BQ 65.23 BQ65.23 0
BQ 75.23 BQ75.23 0
BQ 85.23 BQ85.23 0
BQ 85.23 BQ85.23 0
BQ 85.23 BQ85.23 0
Int 95.23 Int95.23 0
Int 105.23 Int105.23 0
Int 95.23 Int95.23 0
Int 95.23 Int95.23 0
I join the Ldg and Bnk fields into the Combine field.
My problem is I need a process to Order the Combine field.
Then loop through the combine field and if it's not equal to the combine field above it the Dupe field is set to 1, if it is equal the field above it I set to 2 and so on,
Expected Result
Ldg , Bnk , Combine , Dupe,
BQ 55.23 BQ55.23 1
BQ 65.23 BQ65.23 1
BQ 75.23 BQ75.23 1
BQ 85.23 BQ85.23 1
BQ 85.23 BQ85.23 2
BQ 85.23 BQ85.23 3
Int 95.23 Int95.23 1
Int 105.23 Int105.23 1
Int 95.23 Int95.23 1
Int 95.23 Int95.23 2
I have done this in VB where in access as I can follow the process but I am lost at the moment in SQL.
Regards & Thanks
Pator