Link to home
Start Free TrialLog in
Avatar of vj_mi
vj_mi

asked on

Updating my temp table

Hi,

I have an SP that puts the output in temp table. The output is as follows:

Date      Trn_Nr      T_Tips      Dept      Gross
7/12/2007      70177      1.07      1      2.1
7/12/2007      70177      1.07      1      2.1
7/12/2007      70177      1.07      1      2.1
7/12/2007      70177      1.07      1      2.1
7/12/2007      70177      1.07      1      1.5
7/12/2007      70177      1.07      1      1.5
7/12/2007      70177      1.07      1      2.3
7/12/2007      70177      1.07      1      2.3
7/12/2007      70177      1.07      1      0.9
7/12/2007      70177      1.07      1      0.9
7/12/2007      70178      0.88      1      10.5
7/12/2007      70178      0.88      1      2.3
7/12/2007      70178      0.88      1      0.9
7/12/2007      70178      0.88      1      0.9
7/12/2007      70179      0.36      1      1.5
7/12/2007      70179      0.36      1      2.1
7/12/2007      70180      0.09      1      1.5
7/12/2007      70181      0.63      1      2.1
7/12/2007      70181      0.63      1      2.1
7/12/2007      70181      0.63      1      2.1
7/12/2007      70182      2.22      1      2.9
7/12/2007      70182      2.22      1      2.9

Now what I need is that T_Tips should come once for each Trn_Nr and not in every row. So the first record for Trn_Nr 70177 should have value 1.07 and rest should be 0 for same Trn_Nr. Again for Trn_Nr 70718, the first record should have value 0.88 and the rest should have value 0 for same Trn_Nr. Since this data is in Temp table, can I fire one single query? If I use cursor and loop, it will be very time-consuming since we have nearly 80,000 records.

Regards,
MI
ASKER CERTIFIED SOLUTION
Avatar of adathelad
adathelad
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial