It actually is an unusual use case. That being said, you can use the distinct keyword in your queries.
Since you’re new to Pimcore and Symfony, I suggest you read up on the Listings of Pimcore described here: https://pimcore.com/docs/5.x/Development_Documentation/Objects/Working_with_PHP_API.html#page_Object-Listings
The question is, what type of an attribute is it? Different attributes have different implementations. If I understood correctly, you’d like to, for example, take all values of all attributes in all objects of a single class for, say, filtering purposes or something like that?
If that is the case, then you also want to look at this: https://pimcore.com/docs/5.x/Development_Documentation/E-Commerce_Framework/Filter_Service/index.html
Be aware, though, that the Filter Service is only available if you have the E-Commerce Framework installed.
In any case, I would recommend to heavily use the PHP API. The less SQL statements, the better, since there’s always a chance of doing irreparable damage to your database. And the database model is actually more convoluted than you might think.
To achieve something like that through PHP, though, the chunk of code would be this:
$listing = new DataObject/Class/Listing();
$attributeArray = array_unique(
That’s, of course, assuming, that your class is actually named Class, and the attribute you’re trying to get is named Attribute, and that it returns a single value (is text, or a relation to an object, or something like that). If it’s a selection, then you have different options (the class definition itself has all the options saved already).
Hope this helped out a bit.