List:General Discussion« Previous MessageNext Message »
From:Adrian Bruce Date:October 31 2007 2:42pm
Subject:Re: Query question.
View as plain text  
you need to group the result sets by date, look at the manual link below:

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

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?
>
> Thanks for the help.
>
> Richard
>
>   

Thread
Query question.Richard Reina31 Oct
  • Re: Query question.Adrian Bruce31 Oct
  • Re: Query question.Joerg Bruehe31 Oct