CodeInQueries
CodeInQueries
  • 364
  • 44 817
How to Compute the Product of Numbers | SQL Interview Question
Welcome to CodeInQueries! 🧑‍💻 In this video, we’ll cover a common SQL interview question: How to compute the product of numbers in SQL. While SQL has built-in functions like SUM() and AVG(), there’s no direct function for calculating the product of numbers. We’ll show you how to work around this using advanced SQL techniques.
🔹 Topics Covered:
solution 1:-
Using SQL to compute the product of numbers in a column
Applying EXP() and LOG() functions to simulate the product
Understanding the limitations of SQL and creative solutions
solution 2:-
using recursive cte
🔹 Scenario: Suppose you have a table of numbers and you want to compute the product of these numbers across rows. Since there is no built-in PRODUCT() function in SQL, we'll show you an alternative method using logarithmic and exponential functions.
In this query:
We use LOG() to take the logarithm of each number in the column.
We sum the logarithms and then use EXP() to get the product, which is the inverse of taking the logarithm.
💡 Note: Make sure the numbers in the column are greater than zero, as logarithms of zero or negative numbers are undefined.
🔔 Subscribe to CodeInQueries for more advanced SQL tips, interview prep content, and hands-on tutorials.
👍 Like, comment, and share if this video helped you!
#SQLInterviewQuestions #ProductOfNumbers #AdvancedSQL #SQLServer #DataProcessing #LearnSQL #SQLTips #CodeInQueries #DatabaseManagement #SQLForBeginners
zhlédnutí: 99

Video

Find the Highest and Lowest Populations City of each States | SQL Interview Questions
zhlédnutí 144Před dnem
Find the Highest and Lowest Populations City of each States | SQL Interview Questions
How to Delete Duplicate Records | SQL Tutorial
zhlédnutí 137Před dnem
How to Delete Duplicate Records | SQL Tutorial
Type Casting and Escape Characters in Python | Python Tutorial for Beginners
zhlédnutí 36Před 14 dny
Type Casting and Escape Characters in Python | Python Tutorial for Beginners
How to Mask Credit Card Numbers in SQL | SQL Interview Questions
zhlédnutí 112Před 14 dny
How to Mask Credit Card Numbers in SQL | SQL Interview Questions
Data Types in Python | Python Tutorial for Beginners
zhlédnutí 38Před 14 dny
Data Types in Python | Python Tutorial for Beginners
SQL Query Challenge: Understanding NULL and Conditional Logic
zhlédnutí 77Před 21 dnem
SQL Query Challenge: Understanding NULL and Conditional Logic
Python Keywords and Identifiers | Python Basics for Beginners
zhlédnutí 19Před 21 dnem
Python Keywords and Identifiers | Python Basics for Beginners
Find the Maximum ID After Removing Duplicates | SQL Interview Questions
zhlédnutí 110Před 21 dnem
Find the Maximum ID After Removing Duplicates | SQL Interview Questions
Introduction of Python | Python for Data Analysis
zhlédnutí 42Před 21 dnem
Introduction of Python | Python for Data Analysis
Find the Length of the Third Consecutive Date Streak | SQL Server Tutorial
zhlédnutí 139Před měsícem
Find the Length of the Third Consecutive Date Streak | SQL Server Tutorial
Employees who earn less than their friends || SQL Interview Questions
zhlédnutí 69Před měsícem
Employees who earn less than their friends || SQL Interview Questions
Create Function for Split Full Name into First, Middle, and Last Name | SQL Server Tutorial
zhlédnutí 314Před měsícem
Create Function for Split Full Name into First, Middle, and Last Name | SQL Server Tutorial
Replace Numeric Values from alphanumeric value in SQL Server
zhlédnutí 96Před měsícem
Replace Numeric Values from alphanumeric value in SQL Server
Create a Stored Procedure for Delete Duplicates from any table || SQL Server
zhlédnutí 309Před měsícem
Create a Stored Procedure for Delete Duplicates from any table || SQL Server
How to Create Age Range without using case statement | SQL Interview Questions
zhlédnutí 224Před měsícem
How to Create Age Range without using case statement | SQL Interview Questions
Average Time of Process per Machine || Leetcode SQL Question
zhlédnutí 26Před měsícem
Average Time of Process per Machine || Leetcode SQL Question
Percentage of Users Attended a Contest | Leetcode SQL Questions
zhlédnutí 31Před měsícem
Percentage of Users Attended a Contest | Leetcode SQL Questions
SQL PRACTICE QUESTION
zhlédnutí 129Před měsícem
SQL PRACTICE QUESTION
SQL Interview Questions | Ace Your Data Analyst Interview
zhlédnutí 220Před měsícem
SQL Interview Questions | Ace Your Data Analyst Interview
While Loop in SQL Server || SQL Tutorial
zhlédnutí 125Před měsícem
While Loop in SQL Server || SQL Tutorial
Bank Account Summary II || Leetcode SQL Questions
zhlédnutí 35Před měsícem
Bank Account Summary II || Leetcode SQL Questions
Temporary Tables in SQL | SQL Tutorial
zhlédnutí 86Před měsícem
Temporary Tables in SQL | SQL Tutorial
Subquery, Correlated Subquery, CTE, and Recursive CTE in SQL | SQL Tutorial
zhlédnutí 77Před měsícem
Subquery, Correlated Subquery, CTE, and Recursive CTE in SQL | SQL Tutorial
Customer Who Visited but Did Not Make Any Transactions || Leetcode SQL Questions
zhlédnutí 33Před 2 měsíci
Customer Who Visited but Did Not Make Any Transactions || Leetcode SQL Questions
Patients With a Condition || Leetcode SQL Questions
zhlédnutí 17Před 2 měsíci
Patients With a Condition || Leetcode SQL Questions
Find Users With Valid Emails || Leetcode SQL Questions
zhlédnutí 35Před 2 měsíci
Find Users With Valid Emails || Leetcode SQL Questions
Group Sold Products By The Date || Leetcode SQL Question
zhlédnutí 33Před 2 měsíci
Group Sold Products By The Date || Leetcode SQL Question
Top Travellers || Leetcode SQL Questions
zhlédnutí 25Před 2 měsíci
Top Travellers || Leetcode SQL Questions
Capital Gain Loss || Leetcode SQL Questions
zhlédnutí 27Před 2 měsíci
Capital Gain Loss || Leetcode SQL Questions

Komentáře

  • @deepanshurathore9661
    @deepanshurathore9661 Před 3 hodinami

    You should explain the question first.

    • @CodeInQueries
      @CodeInQueries Před 3 hodinami

      @@deepanshurathore9661 bro this not a first part in first part I explained the question

  • @ZartabHasan
    @ZartabHasan Před 4 dny

    Thank you for your efforts to explain these complex quarries, I understood the explanation but did not understand why why used row_number =1 , I would appreciate your clarification from the same.

  • @BIwithYash
    @BIwithYash Před 5 dny

    Full video dalo na adha hi hai ye Bhai

  • @saurabhgaur9270
    @saurabhgaur9270 Před 6 dny

    SSIS pr v playlist start kro sir ❤🎉

    • @CodeInQueries
      @CodeInQueries Před 5 dny

      After completing python I will think about starting ssis

  • @nishchaljain9351
    @nishchaljain9351 Před 9 dny

    Grt job..1 advice...It would be better if u also provide the data scripts so we can also practice the questions in our machine

  • @muralikanala2100
    @muralikanala2100 Před 16 dny

    Could please provide the dataset for this video 😊

    • @CodeInQueries
      @CodeInQueries Před 16 dny

      I suggest you to restore adventuresworklt database bak file ... Download it from Google

    • @muralikanala2100
      @muralikanala2100 Před 16 dny

      Is it there in adventure worklt

    • @CodeInQueries
      @CodeInQueries Před 16 dny

      @@muralikanala2100 yes

  • @princekhunt13579
    @princekhunt13579 Před 17 dny

    Well explained brother

  • @sanyattaneja8551
    @sanyattaneja8551 Před 18 dny

    with cte as( select *, min(order_date) firstOrder from Delivery group by customer_id ) select round(sum(firstOrder = customer_pref_delivery_date) * 100 / count(*), 2) immediate_percentage from cte; why is this not working?

  • @varunm3309
    @varunm3309 Před 19 dny

    101, 450

  • @putulsaini6788
    @putulsaini6788 Před 23 dny

    sir please upload daily video of python, its very helpful and in hindi we clearly understand each line, please upload daily

    • @CodeInQueries
      @CodeInQueries Před 23 dny

      Okay I will try but it's not possible... because after my office I have to record then I need time to edit

  • @CharanchanduKilari-qq2vh

    First like

    • @CodeInQueries
      @CodeInQueries Před 24 dny

      @@CharanchanduKilari-qq2vh thankyou 😊👍

  • @akshaykarande6391
    @akshaykarande6391 Před 26 dny

    Getting error “ the query processor could not produce a query plan because the target DML table is not hash partitioned” Able to read duplicates but only delete is not working

    • @CodeInQueries
      @CodeInQueries Před 26 dny

      Don't know bro it's working for me I think you don't have permission

    • @akshaykarande6391
      @akshaykarande6391 Před 26 dny

      @@CodeInQueries i have created new table with by setting distribution method to hash and its working fine.

  • @A2ZNETWORKS
    @A2ZNETWORKS Před 26 dny

    👍👍👍👍👍

  • @vikasraikwar6192
    @vikasraikwar6192 Před 27 dny

    ❤😮tq sir

  • @akashkhantwal2430
    @akashkhantwal2430 Před měsícem

    I am fresher preparing for data analystics domain, for queries will it be enough for me to solve the question you tell in your playlist as fresher or extra is there any need to do.

    • @CodeInQueries
      @CodeInQueries Před měsícem

      @@akashkhantwal2430 if you solved hacker rank SQL question and Leetcode SQL question that's enough for freshers

  • @akashkhantwal2430
    @akashkhantwal2430 Před měsícem

    Thank you sir for making this type of video,, its help me a lot☺

  • @aswinsimhadri7656
    @aswinsimhadri7656 Před měsícem

    🙏🙏❤

  • @harshilmaru7096
    @harshilmaru7096 Před měsícem

    The best channel for SQL i would say you are doing a great work brother Keep it Up!

  • @vikasraikwar6192
    @vikasraikwar6192 Před měsícem

  • @akashkhantwal2430
    @akashkhantwal2430 Před měsícem

    Is null

  • @Bikinibabesmodels
    @Bikinibabesmodels Před měsícem

    Recursive procedure bhi batao na explain pls

  • @arjunzarekar1740
    @arjunzarekar1740 Před měsícem

    split full name in 3 column using store procedure please create video on this question eg. full name - ABC PQR XYZ OP: FIRST NAME ! Middle Name ! Last name ABC ! PQR ! XYZ

    • @CodeInQueries
      @CodeInQueries Před měsícem

      @@arjunzarekar1740 I will create function for it. Because we can't call stored procedure in select Query

  • @ashishvats1515
    @ashishvats1515 Před měsícem

    Great video, sir. I'm new to cloud data engineering and I want to learn advanced SQL. Could you please help me?

  • @HemanthKumar-f8v
    @HemanthKumar-f8v Před měsícem

    SQL> select e.*,concat(concat(trunc((age-1)/10)*10+1,'-'),trunc(((age-1)/10)+1)*10) as employee_age from employee_age e; EMP_ID AGE EMPLOYEE_AGE ---------- ---------- --------------------------------------------------------------------------------- 1 5 1-10 2 16 11-20 3 19 11-20 4 31 31-40 5 50 41-50

  • @mishrajee861
    @mishrajee861 Před měsícem

    Union

  • @shaikharif1352
    @shaikharif1352 Před měsícem

    Complete nahi ho raha hai ek bhi query

  • @shaikharif1352
    @shaikharif1352 Před měsícem

    A

  • @shaikharif1352
    @shaikharif1352 Před měsícem

    A

  • @shaikharif1352
    @shaikharif1352 Před měsícem

    Bhai query kaha hai

  • @shaikharif1352
    @shaikharif1352 Před měsícem

    A

  • @shaikharif1352
    @shaikharif1352 Před měsícem

    Bhai pura query nahi hoa video khatam hogaya us se pahle hi.

    • @CodeInQueries
      @CodeInQueries Před měsícem

      @@shaikharif1352 ohh sorry I will create full video soon

  • @amanxyz03
    @amanxyz03 Před měsícem

  • @mohit_y23
    @mohit_y23 Před měsícem

    This helps me a lot thank u so much sir ♥

  • @nadimintisekhar8840
    @nadimintisekhar8840 Před měsícem

    Please provide course notes

    • @CodeInQueries
      @CodeInQueries Před měsícem

      Visit my insta @codeinqueries in profile notes link is added

  • @anuragborse9800
    @anuragborse9800 Před měsícem

    A,c

  • @priyankachahande1909
    @priyankachahande1909 Před měsícem

    not able to see complete out put, if you minimize your image then it is possible to see. Request you to please minimize your image. Thank you!

    • @CodeInQueries
      @CodeInQueries Před měsícem

      @@priyankachahande1909 really Sorry I will take care of it from next time

    • @priyankachahande1909
      @priyankachahande1909 Před 23 dny

      @@CodeInQueries Thank you !! Videos are really helpful

  • @souravsharma5804
    @souravsharma5804 Před měsícem

    row_number() built-in function hai? and row_number() ke sath over() q use kiya hai aapne?

    • @CodeInQueries
      @CodeInQueries Před měsícem

      Row_number() ek windows function hai or windows function mein over use hoga

    • @souravsharma5804
      @souravsharma5804 Před měsícem

      @@CodeInQueries thank you

  • @souravsharma5804
    @souravsharma5804 Před měsícem

    bro cte to table name hai na yha pr cte ke place par aur dusra koi sa v name bhi likh sakte hai na and row_number() built-in function hai? and row_number() ke sath over() q use kiya hai aapne?

  • @omernomaan5556
    @omernomaan5556 Před měsícem

    a

  • @priyankachahande1909
    @priyankachahande1909 Před měsícem

    Nice videos ....Please continue posting leetcode videos.

    • @CodeInQueries
      @CodeInQueries Před měsícem

      @@priyankachahande1909 thank you, yes I will post more videos

  • @tusharsharma9711
    @tusharsharma9711 Před měsícem

    Upload answer also, I hope you know yourself. Otherwise it's just useless.

  • @YashBhagwani-007
    @YashBhagwani-007 Před měsícem

    Imma revise SQL and reply with the code, last wrote 3 months ago

  • @SumanSadhukhan-md4dq
    @SumanSadhukhan-md4dq Před 2 měsíci

    But this solution has a flaw... Like if 20,21 20,21 present two time ... I mean duplicate row then also thos query will consider it as a symmetrical pair...

  • @SumanSadhukhan-md4dq
    @SumanSadhukhan-md4dq Před 2 měsíci

    Best approach 🔥🔥🔥

  • @himanshuchauhan3267
    @himanshuchauhan3267 Před 2 měsíci

    mahaan ho bhai mahaan...

    • @CodeInQueries
      @CodeInQueries Před 2 měsíci

      @@himanshuchauhan3267 thank you 😊🙏

  • @souravsharma5804
    @souravsharma5804 Před 2 měsíci

    Bhai koi other way bhi hai ky aisey solv krne ka

    • @CodeInQueries
      @CodeInQueries Před 2 měsíci

      Hosakta hai but easy way hai case use karke

  • @user-th5mq7so6i
    @user-th5mq7so6i Před 2 měsíci

    Keep up the good work 😊

  • @himanshuchauhan3267
    @himanshuchauhan3267 Před 2 měsíci

    didn't understand the COUNT() part...if any pair having count = 1 then it can also be a pair ??

    • @CodeInQueries
      @CodeInQueries Před 2 měsíci

      In symmetric pair one pair need to come two times like 20 21 and 21 20 both are symmetric pair

  • @professor_DJ_010
    @professor_DJ_010 Před 2 měsíci

    bhai yaar aapne jo logic lagaya usme mano id 6 repeat hoga 3 tym to usme row_num 1,2,3 aayega .. to usme toh id - row_num =0 nahi hoga ..

    • @CodeInQueries
      @CodeInQueries Před 2 měsíci

      @@professor_DJ_010 sare 6 consecutive nhi hoga bs ek hoga

    • @CodeInQueries
      @CodeInQueries Před 2 měsíci

      @@professor_DJ_010 duplicate nhi aayega

  • @professor_DJ_010
    @professor_DJ_010 Před 2 měsíci

    bhut ache se samjhaye bhaiya ji