Skip to Content
0
Former Member
Jan 26, 2016 at 05:15 PM

Group on measures not working

16 Views

Hi, I want to find out the most common values for field "x", and "x" is a measure with DECIMAL type. So I ran the 1st sql, The output has only 1 record with some random value for "x". I know "x" has many different values. If "x" is NVARCHAR, it works well. But when "x" is DECIMAL, it doesn't work. I have to run the 2nd sql in order to get the results. But I'm concerned about performance issues of the 2nd sql, does it use too much computing resources? Can someone help? Thanks.

SELECT "x", count(*) as cnt

FROM "table1"

GROUP BY "x"

ORDER BY cnt DESC

SELECT "x", count(*) as cnt

FROM (SELECT "x" FROM "table1")

GROUP BY "x"

ORDER BY cnt DESC