September 29, 2010 at 12:05 pm
Hello All,
I have a query which is returning columns in various datatypes. this query uses the group by clasue for aggregation. I know i can get the max value that are not specified in the group by clause. But this doesn't work with BIT column.
So, is there a way to return the bit columns along with other columns and not have it in the group by clause?
Thank you in advance for your quick response...
September 29, 2010 at 12:13 pm
If you cast it to a numeric type (tinyint) you should be able to use MAX.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 29, 2010 at 12:22 pm
You could convert it to integer to use it for aggregation:
MIN(CAST(YourBitCol AS TINYINT))
or the lazy-dev version:
MIN(YourBitCol + 0) -- force an implicit conversion
Edit: @Gail: the echo was not intentional...
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply