Reply
Please Help...SQL problem (total)
Old 12-19-2006, 02:17 AM Please Help...SQL problem (total)
Junior Talker

Posts: 2
Hello, i need help on this, appreciate very much:

ID Price Amount
-- ---- -------
1 15 4
2 20 2

How to display out the total of it? Example above, the total should be 100, but how to apply it in programming environment.

Thanks very much for the contribute help.
mick3256 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 12-19-2006, 07:38 AM Re: Please Help...SQL problem (total)
chrishirst's Avatar
Super Moderator

Posts: 12,741
Location: Blackpool. UK
in SQL

SELECT SUM(price * amount) as total_value
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-19-2006, 11:16 AM Re: Please Help...SQL problem (total)
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Make sure you add "from {table}". Just in case...Hirst didn't because you didn't supply the table name. But just because I see that question being asked, it's:

Select Sum (price * amount) from {table} <--- replace this part with the name of your table.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-19-2006, 06:32 PM Re: Please Help...SQL problem (total)
chrishirst's Avatar
Super Moderator

Posts: 12,741
Location: Blackpool. UK
Good catch
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-19-2006, 06:50 PM Re: Please Help...SQL problem (total)
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Someone's gotta make sure you're corrected on the 2 times a year you mess up. The 4998 times you're right have nothing to do with it.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 12-21-2006, 03:14 AM Re: Please Help...SQL problem (total)
Junior Talker

Posts: 2
Thanks man
mick3256 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Please Help...SQL problem (total)
 

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12676 seconds with 13 queries