Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Follow us on Facebook Follow us on Twitter Linked In Flickr Watch us on YouTube Google+
Results 1 to 2 of 2
  1. #1
    Junior Member miks's Avatar
    Join Date
    Jan 2009
    Posts
    2
    Downloads
    0
    Uploads
    0

    SQL Question. Complete rookie question but still need answer?

    hello I am a newb in sql and working my baby steps trough it doin quite well except this one question am struggling with. Can anyone here shed some light in my matter please
    I have provided syntax as far as I got myself. I have 2 tables there too they need to be merged. Not too worried about the sort as that is not whats stopping me here

    Suppose you need to know the employee name and department name of all employees that work in a department that has at least 3 employees.
    Write a SQL query to retrieve this information. Order the list in alphabetical order first by department name, then by employee name.

    SELECT NAME,DEPTNAME

    FROM EMPLOYEE,DEPT
    WHERE COUNT(DEPTNAME) >2
    AND EMPLOYEE.DEPTNO=DEPT.DEPTNO;

  2. #2
    Senior Member davidm's Avatar
    Join Date
    May 2008
    Posts
    311
    Downloads
    0
    Uploads
    0
    Your COUNT(DEPTNAME) thing wont work without a GROUP BY. Long story short, this is probably not what you're after. Is there a data field on the DEPT table called something like Number of staff or Number of employees? It seems like there should be.

    Once you change this, your query should work.


Similar Threads

  1. Replies: 4
    Last Post: 10-07-2011, 04:03 AM
  2. Replies: 2
    Last Post: 12-25-2008, 05:59 PM
  3. Replies: 0
    Last Post: 12-04-2008, 04:16 PM
  4. when you answer a question that renders the question useless then the
    By shady in forum Random Interesting Topics
    Replies: 0
    Last Post: 07-22-2008, 08:35 PM
  5. Replies: 0
    Last Post: 05-15-2008, 12:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -4. The time now is 11:50 AM.
Powered by vBulletin® Version 4.2.5
Copyright © 2024 vBulletin Solutions Inc. All rights reserved.