troubleshooting Question

Updating my temp table

Avatar of vj_mi
vj_mi asked on
Microsoft SQL Server 2005
1 Comment1 Solution182 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros