Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Database Administration

Author  Topic 

dlmagers10
Starting Member

48 Posts

Posted - 2010-11-21 : 20:18:59
I need to write and execute a command to retrieve the branch number and units for each branch having more than 25 books on hand.

Tables

BRANCH: BRANCH_NUM, BRANCH_NAME, BRANCH_LOCATION, NUM_EMPLOYEES

INVENTORY: BOOK_CODE, BRANCH_NUM, ON_HAND

THIS IS WHAT i HAVE SO FAR:

SELECT BRANCH.BRANCH_NUM, INVENTORY.ON_HAND
FROM INVENTORY, BRANCH
WHERE BRANCH.BRANCH_NUM = INVENTORY.BRANCH_NUM
AND INVENTORY.ON_HAND > '25';

ALL I AM COMING UP WITH IS THE TWO COLUMN HEADINGS: BRANCH_NAME AND NUM_EMPLOYEES.

I DEFINITELY NEED HELP WITH THIS ONE. PLEASE.

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2010-11-21 : 20:52:44
SELECT BRANCH.BRANCH_NUM, SUM(INVENTORY.ON_HAND) as UnitsOnHand
FROM BRANCH JOIN INVENTORY
ON BRANCH.BRANCH_NUM = INVENTORY.BRANCH_NUM
GROUP BY BRANCH.BRANCH_NUM
HAVING SUM(INVENTORY.ON_HAND)>25

Good luck with the rest of your homework



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

dlmagers10
Starting Member

48 Posts

Posted - 2010-11-22 : 10:08:10
Thank you.
Go to Top of Page
   

- Advertisement -