←back to thread

SQL Design Patterns (2010)

(vadimtropashko.wordpress.com)
149 points mci | 3 comments | | HN request time: 0.612s | source
Show context
potatoproduct ◴[] No.45077193[source]
Not ashamed to admit that I never really thought about the distinct operator 'being redundant' as its essentially just a group by.
replies(3): >>45077523 #>>45078843 #>>45079717 #
1. paulddraper ◴[] No.45079717[source]
SELECT DISTINCT is often a code smell. (Not always.) If you see it, there’s a 70% chance it got slapped on to fix an issue that should have been solved a different way.

SELECT DISTINCT ON is different, and useful.

replies(1): >>45081149 #
2. aspaviento ◴[] No.45081149[source]
I had a teacher who had specific rules for exams when we wrote SQL statements:

- For a question worth 2 points, if you use the word "DISTINCT" when it wasn't needed, you lose 0.5 points.

- If you don't use "DISTINCT" when it was necessary, you lose all 2 points.

replies(1): >>45083817 #
3. 9dev ◴[] No.45083817[source]
Oh yes, introducing a little game theory anxiety into exam questions sounds like a wonderful little torturing tool!