Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge same values into one single column and add values cooresponding

Status
Not open for further replies.

incognito

Technical User
Feb 1, 2001
8
US
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
 
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:
 
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
 
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:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top