AMAZON DATA ENGINEER Interview Question | SQL Intermediate Question 10

Поділитися
Вставка
  • Опубліковано 14 жов 2024
  • Question - Find total transactions through Cash and Online mode.
    The question has been solved using aggregate functions and case condition.
    #amazon #netflix #facebook #google #microsoft #flipkart #sqldeveloper #dataanalytics #dataengineering #sqlserver #placement #placements #interviewquestions #ml #ai

КОМЕНТАРІ • 8

  • @nareshgiduthuri7847
    @nareshgiduthuri7847 4 місяці тому

    Thanks for your content.
    Can you please add below in description which would help
    create table merchant(merchant_id varchar(20) , amount int, payment_mode varchar(20));
    insert into merchant values ('m1',200,'cash'),('m2',520,'online'),('m1',700,'online'),('m3',1400,'online'),('m2',50,'cash'),('m1',300,'cash');
    select * from merchant;

  • @king-hc6vi
    @king-hc6vi 5 місяців тому +1

    Can we do partition on Payment mode and seperate the online and cash mode with row number as 1 for cash and row number as 2 for online....
    And then case statement in which sum of R1 gives the value and puts 0 for online.
    Similarly another case statement in which sum of R2 gives the value and puts 0 for cash.
    Please let me know if this approach is correct or not.

  • @vijaygupta7059
    @vijaygupta7059 5 місяців тому

    same solution as you in MSSQL DB
    Select merchant_id
    ,sum(case when payment_mode = 'cash' then amount else 0 end ) as Cash
    ,sum(case when payment_mode = 'online' then amount else 0 end ) as Online
    from payments
    group by merchant_id
    order by sum(case when payment_mode = 'cash' then amount else 0 end) desc

  • @ushasworld5223
    @ushasworld5223 9 місяців тому

    Could u please provide data set so that we can practice along with u

    • @Code-Con
      @Code-Con  9 місяців тому

      Will definitely provide in the upcoming videos.

  • @apurvasaraf5828
    @apurvasaraf5828 9 місяців тому

    data?

    • @Code-Con
      @Code-Con  9 місяців тому

      Will definitely provide in the upcoming videos.

  • @SKAMRANPASHA
    @SKAMRANPASHA 9 місяців тому

    Group by merchant_id , cash_mode