I have the following table
MyTable
ID
MessageType
MessageDate
MessageBody
A table represents several million rows, but it has only 100 unique MessageType.
I need a sample of each type of MessageType (should include at least MessageType and MessageBody), but I can not do it DISTINCT, because it receives only the MessageType column.
I think something like
SELECT TOP 5 *
FROM MyTable
WHERE MessageType IN (SELECT DISTINCT MessageType FROM MyTable)
I know that this does not work, since this is only I am the top 5, but I am not sure how to make the SQL loop through this.
Thanks for any help
source
share