Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: Query question.

From: Joerg Bruehe <joerg(at)mysql.com>
Date: Wed Oct 31 2007 - 10:47:11 EDT


Hi Richard,

Richard Reina wrote:
> I have a database table paycheck like this.
> empno, date, gross, fed_with
> 1234 "2007-09-01" 1153.85 108.26
> 1323 "2007-09-01" 461.54 83.08
> 1289 "2007-09-01" 1153.85 94.41
> 1234 "2007-09-15" 1153.85 108.26
> 1323 "2007-09-15" 491.94 87.18
> 1289 "2007-09-15" 1153.85 94.41
>
>
> I can easily do a query like this
>
> select (SUM(gross) * .153) + SUM(fed_with) FROM paycheck where
> DATE="2007-09-01";
>
> But then I have to do a query for each pay date in the pay period.
>
> Accordingly, what would be really useful on a day like today would be to be
> able to do a query like the following:
>
> select (SUM(gross) * .153) + SUM(fed_with) FROM paycheck where DATE IS
> distinct;
>
> Does anyone know how to do this?

it seems you want to use "group by":
SELECT (SUM(gross) * .153) + SUM(fed_with) FROM paycheck GROUP BY date;

See here:
http://dev.mysql.com/doc/refman/5.0/en/select.html http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html

HTH,
Joerg

-- 
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Wed Oct 31 10:48:29 2007

This archive was generated by hypermail 2.1.8 : Thu Jul 03 2008 - 08:43:59 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library