SQL Server Performance

count once in multiple records

Discussion in 'General DBA Questions' started by Sidd, Jul 30, 2007.

  1. Adriaan New Member

    What result are you getting with my proposed query? Please post your actual version of that query.
  2. ajitgadge New Member

    is this work for u?
    select @@rowcount (select coun (*) from table group by customerno,reperestentativeno)
  3. ajitgadge New Member

    sorry it is like select count(*) from ( select coun(*) from test group by customerno,repno) as test1
  4. i2lovefishing New Member

    Adriaan, Thank you for the kind words.
    Sidd,
    if a table ZCustomerCallRecord only has 4 fields, with data as -
    CustomerNumber RepresentativeID RecordDate Recordtime
    1 101 2007-07-31 00:00:00 8:00
    2 102 2007-07-31 00:00:00 9:00
    3 105 2007-07-31 00:00:00 10:00
    1 101 2007-07-31 00:00:00 8:05
    1 101 2007-07-31 00:00:00 8:10
    1 105 2007-07-31 00:00:00 17:00
    2 103 2007-07-31 00:00:00 9:05

    The following script will give you the call count (5) for the date of 7/31/2007.
    select count(*) from (select distinct CustomerNumber, RepresentativeID, CONVERT(CHAR(10), RecordDate, 120) as rd from ZCustomerCallRecord) as MyVirtualTable

Share This Page