#1
  1. World Domination
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    San Diego
    Posts
    126
    Rep Power
    12

    SELECT DISTINCT and COUNT


    I'm trying to write a query for an access database to give me distinct dates letters were sent out and the number that were sent out that day, and I'm having some trouble. My SQL book gives the following example:

    Code:
    SELECT COUNT(DISTINCT DateSent)
    FROM Mailings
    
    COUNT(DISTINCT DateSent)
    To which access says syntax error.

    Can anybody help me out? Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,383
    Rep Power
    391
    Code:
    select count(*) from (select distinct datesend 
    from mailings)
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,212
    Rep Power
    4279
    swampboogie, i can't believe you slipped up, you are usually perfect
    distinct dates letters were sent out and the number that were sent out that day
    "distinct dates" --> return more than one row

    "number sent that day" --> number sent each date
    Code:
    select DateSent, count(*) 
      from mailings
    group
        by DateSent
    rudy
    http://r937.com/
  6. #4
  7. World Domination
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    San Diego
    Posts
    126
    Rep Power
    12

    Thumbs up


    thanks guys

IMN logo majestic logo threadwatch logo seochat tools logo