Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 02-15-2005, 09:50 PM   PM User | #1
BigToque
New Coder

 
Join Date: Jan 2005
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
BigToque is an unknown quantity at this point
Is it possible to sum the values of multiple fields on a single SQL record?

I have fields for Goals and Assists.

I want to take those 2 fields and sum them to make a 3rd field PTS, then send them to variable in my PHP code to be printed to the screen.

My statement is this:

SELECT player_stats.G, player_stats.A, SUM (player_stats.G + player_stats.A) PTS
FROM player_stats
WHERE player_stats.PID =10
AND player_stats.season =1

The statement breaks with the bolded part.
BigToque is offline   Reply With Quote
Old 02-15-2005, 10:09 PM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf is on a distinguished road
SELECT player_stats.G, player_stats.A, (player_stats.G + player_stats.A) AS PTS
FROM player_stats
WHERE player_stats.PID =10
AND player_stats.season =1
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 02-15-2005, 10:24 PM   PM User | #3
BigToque
New Coder

 
Join Date: Jan 2005
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
BigToque is an unknown quantity at this point
That worked. Thanks a lot!
BigToque is offline   Reply With Quote
Old 02-15-2005, 10:28 PM   PM User | #4
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf is on a distinguished road
You're welcome
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 03-14-2005, 04:25 PM   PM User | #5
Librarian
New to the CF scene

 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Librarian is an unknown quantity at this point
Sort by the new variable in table display

If you have the display set up in a table with three columns, player_stats.G and player_stats.A and PTS you can sort by the first two fields using <a href='PageName.asp?sort=FieldName'>. How would you sort by the new variable?
Librarian is offline   Reply With Quote
Old 03-15-2005, 01:01 AM   PM User | #6
Kiwi
Regular Coder

 
Join Date: Oct 2002
Posts: 379
Thanks: 0
Thanked 0 Times in 0 Posts
Kiwi is an unknown quantity at this point
SELECT player_stats.G, player_stats.A, (player_stats.G + player_stats.A) AS PTS
FROM player_stats
WHERE player_stats.PID =10
AND player_stats.season =1
ORDER BY PTS
__________________
Strategy Conscious
Kiwi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:30 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.