Coding interview preparation
SQL question: What will this query return?
Hey everyone, quick follow-up to today’s SQL quiz!👇
The query was:
Our active members picked B) 1, C) 0 or D) Error… but let’s break it down real quick! ⚡
➡️ COUNT(*) in the SELECT counts ALL rows in the table → with 10 rows it returns 10
➡️ The HAVING clause filters after aggregation
➡️ HAVING COUNT(*) > 0 simply checks if the total count is greater than 0 (which it always is unless the table is empty)
🟢 So the query returns exactly one row with the value 10.
The question was a valid (just a bit tricky/wordy) way to write
Correct answer: A) 10 ✅
Unfortunately no one got it right😅
Better luck next time folks, you’re all still SQL legends in my book! 💙
The query was:
SELECT COUNT(*) FROM employees HAVING COUNT(*) > 0;
Our active members picked B) 1, C) 0 or D) Error… but let’s break it down real quick! ⚡
➡️ COUNT(*) in the SELECT counts ALL rows in the table → with 10 rows it returns 10
➡️ The HAVING clause filters after aggregation
➡️ HAVING COUNT(*) > 0 simply checks if the total count is greater than 0 (which it always is unless the table is empty)
🟢 So the query returns exactly one row with the value 10.
The question was a valid (just a bit tricky/wordy) way to write
give me the total row count, but only if there’s at least one row
Correct answer: A) 10 ✅
Unfortunately no one got it right😅
Better luck next time folks, you’re all still SQL legends in my book! 💙
❤3
You're giving an interview, and the interviewer asks,
Here's how you can answer:
Sample Answer:
CHAR and VARCHAR2 are both used to store text in SQL, but they work differently. CHAR is fixed-length, meaning it always uses the same amount of space no matter how short the text is. For example, if you set a column to CHAR(10) and store ‘Hi’, it will still take up 10 spaces, adding extra padding to fill the space. This can waste storage but is consistent in size.
VARCHAR2, on the other hand, is variable-length, so it only uses as much space as needed for the text. If you set a column to VARCHAR2(10) and store ‘Hi’, it only takes 2 spaces plus a little extra to store the length, saving space.
Use CHAR when your data is always the same length, like codes or short identifiers. Use VARCHAR2 when your data varies in length, like names or descriptions. CHAR can be slightly faster for fixed-length data, but VARCHAR2 is more efficient for saving space and handling different text lengths.
What is the difference between CHAR and VARCHAR2 datatype in SQL?
Here's how you can answer:
Sample Answer:
CHAR and VARCHAR2 are both used to store text in SQL, but they work differently. CHAR is fixed-length, meaning it always uses the same amount of space no matter how short the text is. For example, if you set a column to CHAR(10) and store ‘Hi’, it will still take up 10 spaces, adding extra padding to fill the space. This can waste storage but is consistent in size.
VARCHAR2, on the other hand, is variable-length, so it only uses as much space as needed for the text. If you set a column to VARCHAR2(10) and store ‘Hi’, it only takes 2 spaces plus a little extra to store the length, saving space.
Use CHAR when your data is always the same length, like codes or short identifiers. Use VARCHAR2 when your data varies in length, like names or descriptions. CHAR can be slightly faster for fixed-length data, but VARCHAR2 is more efficient for saving space and handling different text lengths.
❤3
✅ Top 50 JavaScript Interview Questions 💻✨
1. What are the key features of JavaScript?
2. Difference between var, let, and const
3. What is hoisting?
4. Explain closures with an example
5. What is the difference between == and ===?
6. What is event bubbling and capturing?
7. What is the DOM?
8. Difference between null and undefined
9. What are arrow functions?
10. Explain callback functions
11. What is a promise in JS?
12. Explain async/await
13. What is the difference between call, apply, and bind?
14. What is a prototype?
15. What is prototypal inheritance?
16. What is the use of ‘this’ keyword in JS?
17. Explain the concept of scope in JS
18. What is lexical scope?
19. What are higher-order functions?
20. What is a pure function?
21. What is the event loop in JS?
22. Explain microtask vs. macrotask queue
23. What is JSON and how is it used?
24. What are IIFEs (Immediately Invoked Function Expressions)?
25. What is the difference between synchronous and asynchronous code?
26. How does JavaScript handle memory management?
27. What is a JavaScript engine?
28. Difference between deep copy and shallow copy in JS
29. What is destructuring in ES6?
30. What is a spread operator?
31. What is a rest parameter?
32. What are template literals?
33. What is a module in JS?
34. Difference between default export and named export
35. How do you handle errors in JavaScript?
36. What is the use of try...catch?
37. What is a service worker?
38. What is localStorage vs. sessionStorage?
39. What is debounce and throttle?
40. Explain the fetch API
41. What are async generators?
42. How to create and dispatch custom events?
43. What is CORS in JS?
44. What is memory leak and how to prevent it in JS?
45. How do arrow functions differ from regular functions?
46. What are Map and Set in JavaScript?
47. Explain WeakMap and WeakSet
48. What are symbols in JS?
49. What is functional programming in JS?
50. How do you debug JavaScript code?
💬 Tap ❤️ for detailed answers!
1. What are the key features of JavaScript?
2. Difference between var, let, and const
3. What is hoisting?
4. Explain closures with an example
5. What is the difference between == and ===?
6. What is event bubbling and capturing?
7. What is the DOM?
8. Difference between null and undefined
9. What are arrow functions?
10. Explain callback functions
11. What is a promise in JS?
12. Explain async/await
13. What is the difference between call, apply, and bind?
14. What is a prototype?
15. What is prototypal inheritance?
16. What is the use of ‘this’ keyword in JS?
17. Explain the concept of scope in JS
18. What is lexical scope?
19. What are higher-order functions?
20. What is a pure function?
21. What is the event loop in JS?
22. Explain microtask vs. macrotask queue
23. What is JSON and how is it used?
24. What are IIFEs (Immediately Invoked Function Expressions)?
25. What is the difference between synchronous and asynchronous code?
26. How does JavaScript handle memory management?
27. What is a JavaScript engine?
28. Difference between deep copy and shallow copy in JS
29. What is destructuring in ES6?
30. What is a spread operator?
31. What is a rest parameter?
32. What are template literals?
33. What is a module in JS?
34. Difference between default export and named export
35. How do you handle errors in JavaScript?
36. What is the use of try...catch?
37. What is a service worker?
38. What is localStorage vs. sessionStorage?
39. What is debounce and throttle?
40. Explain the fetch API
41. What are async generators?
42. How to create and dispatch custom events?
43. What is CORS in JS?
44. What is memory leak and how to prevent it in JS?
45. How do arrow functions differ from regular functions?
46. What are Map and Set in JavaScript?
47. Explain WeakMap and WeakSet
48. What are symbols in JS?
49. What is functional programming in JS?
50. How do you debug JavaScript code?
💬 Tap ❤️ for detailed answers!
❤1