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
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...
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:
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 !!!
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.
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
why did u use max(founder)?? what is the role of max here
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...
c1 has 2 senior manager but in employee table there is only one distinct so code output should be wrong on test example ig?
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:
wHY WE use MAX aggregate funcction in founder from employee e
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 !!!
we use aggregate functions just to print even though it is not required.
Nice and simple explanation. Thanks!
why was max(founder) used? Can you explain?
it is aggrgate function , used to find the maximum value row
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.
@@saisouravsahu5064 why don't we just add 'c.founder' to the GROUP BY clause ? It also worked
Thankyou
where is the code?
t.me/dev19community