Skip to content
Advertisement

sql dw count(*) with selected columns doesn’t aggregate

This is rather strange, and I have had this query work on numerous databases but here I am stumped. I know that my Synapse table has duplicates

produces

but when I try to run following

I get the following:-

why does the count not aggregate up?

Advertisement

Answer

Some possibilities –

  1. date has different time/millisecond. so, you can try removing time part and run group by query again.
  2. string column(key) can have white spaces in the end or begining. you can use ltrim/rtrim and run group by query again. Client tool will display them as identical data like your output. By trimming space there can be a true comparison.

In OP’s case, it was case #2. Using ltrim/rtrim resolved the agg issue.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement