Count (formula) - confused?

  • Hi everyone,

    I am looking for a query that would use one column (A) multiplied by another column (B) and it would give me the results I am looking for.

    DataFromColumnA would be UnitQuantity

    DataFromColumnB would be Price

    So far I have

    select CustomerId, Product, COUNT (DataFromColumnA * DataFromColumnB) as TotalPrice from Table

    where CustomerId = '123456' and UnitQuantity > 0

    group by CustomerId, Product

    And the results I get so far is either a 1 or a 0.

    Thank you in advance for your help.

    Celine

  • Why are you using COUNT()? From what you've said it looks like you want SUM()?

  • Thank you!!

    I've used count before that's why I was using it again, didn't even think about SUM!

    Thanks again, have a good day

    🙂

  • No problem!

    For a refresher of the various aggregates and their jobs, check out this page: https://msdn.microsoft.com/en-gb/library/ms173454.aspx

  • Even better!! Thanks again :satisfied:

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply