You are here: Re: Mysql count(condition)? « PHP Programming Language « IT news, forums, messages
Re: Mysql count(condition)?

Posted by Jerry Stuckle on 03/02/06 06:46

no.mail.pls wrote:
> Hi Steve,
>
> Thanks for the reply. It works.
> i am aware that this is not a sql group, but i beg your indulgence, as i am
> quite sure that you guys will respond,
> because i believe that most folks who use PHP
> will also be using mysql.
>
> is that correct?
>
> cheers
> "Steve" <ThisOne@Aint.Valid> wrote in message
> news:pan.2006.03.02.04.04.02.810758@Aint.Valid...
>
>>On Thu, 02 Mar 2006 11:41:12 +0800, dottty wrote:
>>
>>
>>>Hi,
>>>i have a table that has the following fields:
>>>id, name, dept, pay
>>>1, John, Sales, 4000
>>>2, Peter, HR, 5000
>>>etc.
>>>
>>>How do i count how many people there are in each dept with an sql query?
>>>
>>>I find this surprisingly difficult, given the fact that i can sum the
>>>total
>>>pay for each dept by using:
>>>$query="
>>>Select sum(if (dept='HR', pay, 0)) as hrpay, ......
>>>";
>>>
>>>TIA
>>
>>Blimey, is that sql? Given the standard rider about this *not* being a
>>mysql support group, something like the (untested) suggestion below might
>>help:
>>
>>select dept, count(*), sum(pay) from ... group by dept, order by dept;
>>
>>Steve
>>
>
>
>

No, it is not correct. Many use Postgres SQL, SQL Server, other
databases or no database at all.

You should ask MySQL question in a MySQL newsgroup - such as
comp.databases.mysql. *Everyone* there uses MySQL.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация