95% of all code makes me cry. The other 5% are white space.
SELECT oh.*, (SELECT count(id) FROM orderposition p WHERE p.orderHeaderID = oh.id) AS nofPosPerOrder, og.mostImportantPrioInGroup, og.earliestDeliveryTime, og.earliestCreationTime FROM orderHeader oh LEFT JOIN ( SELECT g.orderGroup, min(g.priority) AS mostImportantPrioInGroup, min(g.requestedDeliveryTime AS earliestDeliveryTime, min(g.requestedCreationTime AS earliestCreationTime FROM orderHeader g GROUP BY g.orderGroup) og ON oh.orderGroup = og.orderGroup WHERE ????? ORDER BY .
The above is actually just an average query with a scalar subquery and a derived table as brought to us by M. Lindenmann on Stack Overflow. We've done this before. But those who want to make me cry will obfuscate this simple SQL with a large stack of upstack frameworks (at least 7). You really cannot have enough abstraction over SQL when you want to write SQL.comments powered by Disqus
Send us your own example of code that made you cry! Please include:
Note that we may choose not to publish some submissions if we feel they're not appropriate. We hope you understand.
Use jOOQ, instead of JDBC.
jOOQ generates Java code from your database and lets you build typesafe SQL queries through its fluent API.