×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Merge same values into one single column and add values cooresponding

Merge same values into one single column and add values cooresponding

Merge same values into one single column and add values cooresponding

(OP)
I am trying to figure out what I need to merge all of the multiple values on the same line of FirstName and LastName into one FirstName and LastName column for every name and in doing so add all the BeginningMiles and EndingMiles and have a calculation subtracting EndingMiles from BeginningMiles. Any suggestions will be appreciated.
John

RE: Merge same values into one single column and add values cooresponding


If i've interpreted you need correctly, you'll want write a query like this.

Select FirstName, LastName Sum(EndingMiles - BeginningMiles) As TotMiles
 From tbl
  Group By FirstName, LastName

Terry

I never worry about the future. It comes soon enough. -Albert Einstein

SQL Article links: http://members.home.net/tlbroadbent/sqlarticles.htm

RE: Merge same values into one single column and add values cooresponding

(OP)
Let me try to explain better. The first problem I am having is trying to merge the FirstName and LastName (two separate columns) so I have no duplicates. In doing so, I want it to add up all the BeginningMiles and EndingMiles and then subtract the total EndingMiles from the total BeginningMiles. I was getting syntax errors on the SQL that you gave me for the query.
John

RE: Merge same values into one single column and add values cooresponding


John,

By "merge" do you mean concatenate first and last names in one field?

What errors did the query give you? Just saying it errored doesn't help me debug the query.

The query I gave you will summarize miles on unique FirstName, LastName combinations, eliminating duplicates. That's exactly the way it is done in SQL.

Terry

I never worry about the future. It comes soon enough. -Albert Einstein

SQL Article links: http://members.home.net/tlbroadbent/sqlarticles.htm

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close