Discussion about SQL queries

How a SQL query can be complicated?

How a SQL query can be complicated?

by Sohag Raha -
Number of replies: 0

I think the hardest part about SQL is learning to write queries that execute quickly. I like to write complicated things with multiple joins, multiple nested inner queries, case statements, etc. If you know what you are doing, they can still run fast. A key thing that beginners miss is to make sure you are building the sub query once, not on every record.

Another thing that is tricky to learn and tough to quantify is to write in a style that works well with the mostly undocumented quirks of the database query optimizer. Because SQL is a declarative language, you cannot be certain that the query plan that the database deduces is an optimal fit for what you are doing.