Results 1 to 8 of 8

Thread: display deptname

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Answers
    1

    Arrow display deptname

    how to get the deptname where dept have maximum no of employees in dept


  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: display deptname

    What is the code that you are working on ?

    What you have tried so far ?


  3. #3
    Contributing Member
    Join Date
    Jun 2007
    Answers
    65

    Re: display deptname

    Select top 1 deptname, sum(deptname) as total from dept group by deptname order by total



    ---V V---
    Vikas Vaidya


  4. #4
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: display deptname

    Quote Originally Posted by vikasvaidya View Post
    Select top 1 deptname, sum(deptname) as total from dept group by deptname order by total

    ---V V---
    Vikas Vaidya
    sum(deptname) as total


    how will that work ?


  5. #5
    Contributing Member
    Join Date
    Jun 2007
    Answers
    65

    Re: display deptname

    Quote Originally Posted by debasisdas View Post
    sum(deptname) as total


    how will that work ?
    That's a silly mistake I have done in hurry. Sorry for that.

    Actually we have to use
    Select top 1 deptname, count(employee) as total from Employee group by deptname order by total.



    ---V V---
    Vikas Vaidya


  6. #6
    Junior Member
    Join Date
    Mar 2009
    Answers
    22

    Re: display deptname

    Select top 1 deptname, count(employee) as total from Employee group by deptname order by total.


    hear we will get jest top one departname and count of employes but we need higest count of employes from depart name


  7. #7

    Re: display deptname

    how to get the deptname where dept have maximum no of employees in dept

    I belive any DB this above two field should come in diff Table because both are coming in diff Level so

    select top 1 d.deptname, count(e.empid) as total from emp e,department d where e.deptid = d.deptid
    group by d.deptname
    order by total desc


  8. #8
    Junior Member
    Join Date
    Mar 2009
    Answers
    22

    Re: display deptname

    Thanks pradeep


  9.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact