Distinct values in SQL Server database?

Hello,

I want to display data from a model in a table. The data is grouped into a type of category. This means that several records can logically have the same category. But I now want to use the category as a header. The category should then only appear once and the associated records should be displayed below. Is there a way to use distinct for SQL Server for columns or any other simple way?

I tried the following.

distinct_results = Meeting.objects.order_by('description').distinct('description')

Unfortunately I then get this message.

"DISTINCT" ON fields is not supported by this database.

Best regards
Patrick

If you sort the rows by category such that all rows of each category are together within the queryset, then you could use the ifchanged tag to determine when a new category is encountered.

Hi Ken,

perfect, I will try it tomorrow. Thank you very much.

Best regards
Patrick