Hi All,

Thanks to all those that answered my cry for SQL help. David's query did the
trick. Thanks David

Duane




-----Original Message-----
From: David Cummins [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 28, 2000 12:12 AM
To: [EMAIL PROTECTED]
Subject: Re: Query Help


Hi Duane.

Have you tried correlated subqueries?

i.e.

SELECT  doc_group_id, short_descr,
    (SELECT COUNT(doc_id) AS DocCount FROM documents
    WHERE documents.doc_group_id = d.doc_group_id) AS DocCount
FROM
    doc_groups d
ORDER BY
        short_descr

Duane Boudreau wrote:

> I am using the following query to pull info from a DB and give me the
record
> count for each doc_group_id. I've gotten to this point but this is as far
as
> I can go. Can some SQL guru here lend a hand?
>
> SELECT
>         doc_group_id, short_descr, (SELECT COUNT(doc_id) AS DocCount FROM
documents
> WHERE doc_group_id = ?????) AS DocCount
> FROM
>         doc_groups
> ORDER BY
>         short_descr
>
> Tables
> doc_groups -> doc_group_id, doc_group_descr
> documents -> doc_id, doc_group_id, doc_title
>
> TIA,
> Duane
>
> --------------------------------------------------------------------------
----
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to