home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gossip.pyramid.com!pyramid!unify!atlantis!meh
- From: meh@atlantis.Unify.Com (Mark E. Hansen)
- Newsgroups: comp.databases
- Subject: Re: Interative SQL Query Question
- Message-ID: <gppb1p7@Unify.Com>
- Date: 15 Dec 92 20:26:28 GMT
- References: <lhv4hlINN9ne@jethro.Corp.Sun.COM> <1992Dec5.195857.1775@uunet!cbmvax!xmws!kripalu>
- Sender: meh@atlantis (Mark E. Hansen)
- Organization: Unify Corporation, Sacramento, CA, USA
- Lines: 66
-
- In article <1992Dec5.195857.1775@uunet!cbmvax!xmws!kripalu>, harit@kripalu.com writes:
- |> In article <lhv4hlINN9ne@jethro.Corp.Sun.COM> pmccurdy@alcalde.Corp.Sun.COM
- |> (Patrick McCurdy) writes:
- |> >
- |> > Hi All,
- |> >
- |> > I have been struggling with this one for quite some time, and I
- |> > just can't seem to get it right.
- |> >
- |> > My table has a column called requestor. Now, it is a simple
- |> > matter to find out how many of the rows were requested by any
- |> > specific requestor with:
- |> >
- |> >
- |> > select count(*)
- |> > from TableName
- |> > where Requestor = 'name'
- |> >
- |> >
- |> > But what if I want to select the count for EACH distinct
- |> > requestor? I have tried:
- |> >
- |> >
- |> > declare @REQ varchar(25)
- |> > while (select @REQ = (distinct(Requestor)))
- |> > begin
- |> > select count(*)
- |> > from HRISPerm
- |> > where Requestor = @REQ
- |> > end
- |> >
- |> >
- |> > but this does not work. Any help on this question would be greatly
- |> > appreciated.
- |> >
- |> >
- |> > Patrick McCurdy
- |> > Systems Support Specialist
- |> > Sun Micro
- |>
- |> try something like this:
- |>
- |> select count(*) from HRISPerm group by Requestor
-
- I'm sure you meant:
-
- select count(*), Requestor from HRISPerm group by Requestor
-
- The count by itself wouldn't be very useful.
-
-
- |>
- |>
- |> --
- |> Michael Allen Latta
- |> Kripalu Center
- |> harit@kripalu.com
- |> (413)448-3288
-
- --
- Mark E. Hansen internet: meh@Unify.Com
- Unify Corporation ...!{csusac,pyramid}!unify!meh
- 3901 Lennane Drive voice: (916) 928-6234
- Sacramento, CA 95834-1922 fax: (916) 928-6401
-
- ** If there is no solution, there is no problem **
-