✍️Best practices for writing SQL 📊queries:
1- Write SQL keywords in capital letters.
2- Use table aliases with columns when you are joining multiple tables.
3- Never use select *, always mention list of columns in select clause.
4- Add useful comments wherever you write complex logic. Avoid too many comments.
5- Use joins instead of subqueries when possible for better performance.
6- Create CTEs instead of multiple sub queries , it will make your query easy to read.
7- Join tables using JOIN keywords instead of writing join condition in where clause for better readability.
8- Never use order by in sub queries , It will unnecessary increase runtime.
9- If you know there are no duplicates in 2 tables, use UNION ALL instead of UNION for better performance.
Here you can find essential SQL Interview Resources👇
https://topmate.io/analyst/864764
Like this post if you need more 👍❤️
Hope it helps :)
1- Write SQL keywords in capital letters.
2- Use table aliases with columns when you are joining multiple tables.
3- Never use select *, always mention list of columns in select clause.
4- Add useful comments wherever you write complex logic. Avoid too many comments.
5- Use joins instead of subqueries when possible for better performance.
6- Create CTEs instead of multiple sub queries , it will make your query easy to read.
7- Join tables using JOIN keywords instead of writing join condition in where clause for better readability.
8- Never use order by in sub queries , It will unnecessary increase runtime.
9- If you know there are no duplicates in 2 tables, use UNION ALL instead of UNION for better performance.
Here you can find essential SQL Interview Resources👇
https://topmate.io/analyst/864764
Like this post if you need more 👍❤️
Hope it helps :)