Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2004, 02:29 AM
szy szy is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to sum ??

I have a Table like this?
name producttype price time
Jack chair $3 4-26
Jack desk $8 4-26
jack bed $11 4-26
Tom chair $4 4-26
Tom desk $7 4-26
Tom bed $16 4-26
Jack chair $3 4-27
Jack desk $8 4-27
jack bed $11 4-27
Tom chair $4 4-27
Tom desk $7 4-27
Tom bed $16 4-27
I want to perform a sql query to return results like this:
name pay time
Jack ? 4
Tome ? 4
 how to gain the pay ?
Any hint will be greatly appreciated.



 
Old April 26th, 2004, 04:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this:
Code:
  SELECT name, Sum(price)
    FROM YourTable
GROUP BY name
That will group each of the names together and calculate the sum of the price's for each person.

Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to sum in for-each Gjella XSLT 1 October 2nd, 2006 08:48 AM
Help: Running Sum (or Cumulative Sum) timdasa VB Databases Basics 1 August 22nd, 2006 03:12 PM
sum utarian Access 2 March 28th, 2005 09:42 PM
need sum help! jbik BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 December 20th, 2004 05:27 PM
SUM or What bertlf Pro VB Databases 2 November 29th, 2003 02:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.