TGViewer
Programming Resources | Python | Javascript | Artificial Intelligence Updates | Computer Science Courses | AI Books Programming Resources | Python | Javascript | Artificial Intelligence Updates | Computer Science Courses | AI Books @programming_guide · 56K subscribers
Post #3755 1.32K
30. Write retention query in SQL?

Example logic: Count users who appeared in month X and also in month X+1.
WITH this_month AS ( SELECT user_id FROM users WHERE MONTH(join_date) = '2024-01' ), next_month AS ( SELECT user_id FROM users WHERE MONTH(join_date) = '2024-02' ) SELECT COUNT(*) FROM this_month WHERE user_id IN (SELECT user_id FROM next_month);

31. Write year-on-year growth in SQL?

SELECT year, revenue, revenue - LAG(revenue) OVER (ORDER BY year) AS YoY_Growth FROM sales;

32. Write a query for cumulative sum in SQL?

SELECT date, revenue, SUM(revenue) OVER (ORDER BY date) AS cumulative_revenue FROM sales;

33. Difference between Function and Stored Procedure?

Functions return values and are used in expressions.
Stored Procedures do not return values directly, can contain complex logic.

34. Do we use variable in views?

No, variables cannot be used in views.

35. What are the limitations of views?

Cannot use variables
Can't call stored procedures
Not always updatable
Performance depends on underlying query

Hope it helps :)
  • ❤ 4
More from @programming_guide
  1. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  2. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  3. Sep 29, 2026🧠 Core Programming Concepts You Should Know 💻🚀 These are the fundamental ideas behind a…
  4. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  5. Sep 28, 2026YOU SHOULD WRITE CODE ON PAPER 📜IF U R BEGINNER ... HERE IS WHY 🤔 If you're a beginner l…
  6. Sep 28, 2026🎓 𝗛𝗔𝗥𝗩𝗔𝗥𝗗 𝗨𝗡𝗜𝗩𝗘𝗥𝗦𝗜𝗧𝗬 𝗙𝗥𝗘𝗘 𝗢𝗡𝗟𝗜𝗡𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 😍 Dreaming of…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →