Reply to Re: Mysql count(condition)?

Your name:

Reply:


Posted by Bosconian on 03/02/06 07:39

"no.mail.pls" <no.mail@st.peters> wrote in message
news:44066ee9$0$15795$14726298@news.sunsite.dk...
> Hi,
>
> Thanks for the prompt reply. However, i think it should be GROUP BY dept.
>
> cheers
>
> "Bosconian" <bosconian@planetx.com> wrote in message
> news:_pqdnfMwK-jE95vZnZ2dnUVZ_v6dnZ2d@comcast.com...
> > "dottty" <dottty@noemailpls.met> wrote in message
> > news:4406695a$0$15795$14726298@news.sunsite.dk...
> >> 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
> >>
> >>
> >>
> >
> > SELECT Count(dept) AS deptcount
> > FROM [table]
> > GROUP BY id
> >
> >
>
>

You're right and I know better. Serves me right for responding hastily just
as the pizza's being delivered. :-]

[Back to original 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

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