• stephen99999 (1/11/2012)


    bicky1980 (1/11/2012)


    stephen99999 (1/11/2012)


    Try this bick, and please reply with the results... I am not on a machine with management studio, so can't test.

    SELECT datakey,COUNT(datakey) OVER(Partition by datakey) AS Uniquedatakey,

    COUNT(landline) OVER(Partition by datakey) AS Uniquelandline,

    COUNT(mobile) OVER(Partition by datakey) AS Uniquemobile,

    COUNT(emailD)OVER(Partition by datakey) AS Uniqueemail

    FROM test

    group by datakey

    Column 'test.landline' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

    Either remove the GROUP BY or add the necessary columns to the GROUP BY (the errors will tell you). Or instead of the GROUP BY, just add DISTINCT after SELECT.

    Please reply with results/errors.

    Also, are you not debugging? Really try to work through these issues before replying. This will show the more expert posters that you are trying to learn instead of just get a direct answer.

    -Stephen

    Thanks for the reply... you did ask me to tell you the results, so that is what I did. I am still trying to solve the problem myself too, not just waiting for an solution (if there is one)

    I have never used the debugger (will look into that) - Thanks for the advice. I think I need to use a mixture of the over(), partition(), row_number() and maybe rank() clauses...Maybe...