Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Location
    Austin, TX
    Posts
    6

    Unanswered: counting distint records

    i have an sql statement like this:

    Code:
    SELECT distinct store, dept, sku
    FROM some_table
    WHERE some_condition
    i simply want to modify it to give me the count, i tried this, but it doesn't work:

    Code:
    SELECT count (distinct store, dept, sku)
    FROM some_table
    WHERE some_condition
    what am i doing wrong? thank you very much for your help.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    This is a pure guess, but do you want something like:
    Code:
    SELECT Count(*), store, dept, sku
       FROM some_table
       WHERE  1 = 1 -- or some other condition of your choosing
       GROUP BY store, dept, sku
    -PatP

  3. #3
    Join Date
    Apr 2004
    Location
    Austin, TX
    Posts
    6
    thanks for the help, yeah i think that will work, but i ended up doing something like this:

    Code:
    SELECT count(1)
    FROM (	SELECT	distinct store, dept, sku
    		FROM	some_table
    		WHERE	some_condition
    	)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •