#24 New Companies | HackerRank SQL Solutions

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ต.ค. 2024
  • Please join telegram group for queries...
    t.me/+4-PDdc3l...
    Please follow us
    / dev.19.community
    Thanks for watching us ...
    Dev19🖤

ความคิดเห็น • 22

  • @vivekpanchbhai3625
    @vivekpanchbhai3625 10 หลายเดือนก่อน +7

    max kyu lagaya ka answer ye hai ki wo string output deta to max min sum lagaane pe wo group function jese work karega aur output same dega kyuki neeche group function diya tha

  • @sargunsingh3161
    @sargunsingh3161 ปีที่แล้ว +7

    why did u use max(founder)?? what is the role of max here

    • @aniket.....
      @aniket..... 6 หลายเดือนก่อน

      for use group by function we have to use any aggregate function to define it hence we use random aggreate function I.e MAX
      And
      We can use any aggreate function to use group by on it...

  • @mahimudgal3284
    @mahimudgal3284 25 วันที่ผ่านมา

    c1 has 2 senior manager but in employee table there is only one distinct so code output should be wrong on test example ig?

  • @bnavaneethakrishnan4571
    @bnavaneethakrishnan4571 ปีที่แล้ว +2

    select C. company.
    code,
    C. Founder,
    (select count(distinct lead_manager.
    _code)
    from Lead_Manager as L where L. Company_code =
    C.company_code),
    (select count distinct senior_ manager.
    _code)
    from senior manager as s
    where s.company_code = c. company_code),
    (select count (distinct Manager-_code)
    from manager as M where M. company_ code =
    C. company _code),
    select count distinct
    Employee code
    From Employee as E where E. company_code.
    C.company_ code
    or Company as C order
    C. company code ase:

  • @mdamirhussain2095
    @mdamirhussain2095 2 หลายเดือนก่อน

    wHY WE use MAX aggregate funcction in founder from employee e

  • @ahmadhamzakhan8903
    @ahmadhamzakhan8903 ปีที่แล้ว

    Nice Explanation, but I want to know why you used MAX function. I know the use of MAX function, but why we used it here, since we only want founder name.
    I've also seen other problems where people use any aggregate function even though it is not required just to get the answer. There's definitely some reason behind it.
    Can you please explain me that reason Bro !!!

    • @akshatsharma6325
      @akshatsharma6325 ปีที่แล้ว +1

      we use aggregate functions just to print even though it is not required.

  • @datascience9224
    @datascience9224 ปีที่แล้ว

    Nice and simple explanation. Thanks!

  • @vaibhavichitnis4769
    @vaibhavichitnis4769 ปีที่แล้ว

    why was max(founder) used? Can you explain?

    • @dev.19.community
      @dev.19.community  ปีที่แล้ว

      it is aggrgate function , used to find the maximum value row

    • @saisouravsahu5064
      @saisouravsahu5064 ปีที่แล้ว

      You can use min(founder) too. fact is when we use group by, we have the same founder name for each employee, each lead_manager, each senior_manager who belongs to the same company. If you use only founder, its gonna be wrong as it detects same founder name multiple times, instead you can you any function to select one just like min,max etc.

    • @hakaneskici2771
      @hakaneskici2771 7 หลายเดือนก่อน

      @@saisouravsahu5064 why don't we just add 'c.founder' to the GROUP BY clause ? It also worked

  • @vaibhavsrivastava7945
    @vaibhavsrivastava7945 ปีที่แล้ว

    Thankyou

  • @jececdept.9548
    @jececdept.9548 8 หลายเดือนก่อน

    where is the code?