Results 1 to 3 of 3

Thread: sql (any)

  1. #1
    New Lounger
    Join Date
    May 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sql (any)

    Hi all
    Please how can i get the max result of the query below
    Mdb is :
    EMPLOYEE (ENO, ENAME, POSITION)
    PROJECT (PNO, PRJ-NAME, BUDGET, CNO)
    LOAD (ENO, PNO, LOAD)
    COMPANY (CNO, CNAME, CITY, PHONE)
    Question is:
    Get the company that has the largest number of staff working for its projects.
    Display the company name and the number of employees working for it.
    My qry is (if it's correct?):
    SELECT CNAME, COUNT(LOAD.ENO)
    FROM LOAD, PROJECT, COMPANY
    WHERE LOAD.PNO = PROJECT.PNO AND
    PROJECT.CNO = COMPANY.CNO
    GROUP BY CNAME
    HAVING COUNT(LOAD.ENO) > ANY
    (SELECT COUNT(LOAD.ENO)
    FROM LOAD, PROJECT, COMPANY
    WHERE LOAD.PNO = PROJECT.PNO AND
    PROJECT.CNO = COMPANY.CNO
    GROUP BY CNAME);
    Thankyou

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: sql (any)

    > ANY means that the query will return all companies for which the number of employees working on projects is larger than the number for at least one other company. I think you need >= ALL. This means that the number of employees is greater than or equal to the number for ALL other companies, i.e. it is the maximum.

  3. #3
    New Lounger
    Join Date
    May 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: sql (any)

    Hi
    Thankyou Hans it worked, great help ..
    best regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •