in Search
ATTENTION: I've decided to put the upgrade on hold due to a compatibility issue of our server environment with the latest CS installer package. CS 2008 now requires SQL Server 2005 as the backend DB but our database server currenlty has SQL Server 2000 installed on it. I'll resume the upgrade once I figure out when Telligent is releasing a patch to the schema compatibility issue. For now, we will continue to use the old version of CS while waiting for the said patch. If you have any questions about this process, please don't hesitate to post them on our forums and I'll answer them as soon as I can. Thanks for your patience and support guys! I'll let you know as soon as this is resolved. - Keith Rull
Latest post 05-19-2006 3:11 AM by jokiz. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-18-2006 8:54 AM

    • mbernardo
    • Top 100 Contributor
    • Joined on 12-20-2005
    • Toronto, Canada
    • Posts 10
    • Points 245

    Help! Display 1 row showing total records with GROUP BY

    Help! Consider the following table:

    Sub_ID   Aff_ID   Entry_date   Clicks
    -------------------------------------
    33 232 5/1/2006 1
    42 422 5/2/2006 1
    33 83 5/2/2006 3
    76 333 5/3/2006 1
    ... and so on

    I have the following statement in SQL Query Analyzer:

    SELECT count(*) as counter
    FROM Ad_Stats_Table
    WHERE Aff_ID = 33 AND (Entry_Date between '5/1/2006' and  '5/16/2006')
    Group By Sub_ID

    That query returns 35,830 rows. But it returns the following:

    counter
    -------
    1
    1
    1
    1
    ... (35,830 times!)

    I want it to return just 1 row containing the row count like so:

    counter
    -------
    35830

    Can someone help?

    http://www.filipino.ca http://www.uniqual.ca
    • Post Points: 35
  • 05-18-2006 12:52 PM In reply to

    • keithrull
    • Top 10 Contributor
    • Joined on 08-08-2005
    • San Diego, CA
    • Posts 1,956
    • Points 39,165

    Re: Help! Display 1 row showing total records with GROUP BY

    Try This:

    [code language="T-SQL"]

    select count(*)
    from Ad_Stats_Table
    Where
    Sub_ID = 33
    And
    ( entry_date
     between '5/1/2006' and  '5/16/2006')
    Group By Sub_ID

    [/code]

    or you can also group it by aff_id

    [code language="T-SQL"]

    [/code]

    select count(*)
    from Ad_Stats_Table
    Where
    Aff_ID = 333
    And
    ( entry_date
     between '5/1/2006' and  '5/16/2006')
    Group By Aff_ID

    devpinoy sig

    • Post Points: 5
  • 05-19-2006 3:11 AM In reply to

    • jokiz
    • Top 10 Contributor
    • Joined on 08-10-2005
    • Singapore
    • Posts 1,098
    • Points 18,030

    Re: Help! Display 1 row showing total records with GROUP BY

    the group by is messing your needs, why do you need it, select count(*) will do it with your filter
    • Post Points: 5
Page 1 of 1 (3 items)