Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 18th, 2003, 08:47 AM
gotspy's Avatar
gotspy gotspy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Buffalo, NY
Posts: 156 gotspy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 59 m 53 sec
Reputation Power: 6
Should I use Group By??

I have an inventory tracking system that has a layered inventory built in. I have basically Two tables, Items and Inventory.

The Item table is just that, a list of all of my items. The inventoy table tracks the current quantity and on-hands. (Qty is how many are in the building, on-hand is how many are available for sale)

The inventory table has Receive Date, Item_id, QTY, On_Hand, Slot and Cost_per_item.

The idea is to keep a record of each receiver into my warehouse. (Transfers and sales are kept in a different table.)

I want to create a report for the stock people to reconcile their inventory.

When a new receiver comes in if the item_id and cost_per_item are the same then it just updates the QTY and On_Hand. If the cost_per_item is different then it inserts a new record.

Now if the same item with two different costs are in the same slot location, then it will produce two lines. I'm trying to figure out how I can set up my Select to group the items in a slot so the warehouse person doesn't have to add them up before he counts the stock.

I tried Group By, but I couldn't seem to get it to work. Right now I have

SELECT *
FROM inventory
ORDER BY slot

The other thing I thought about was to do the query as above and then when there are two like items in the same slot add them together and display that. That seems like sloppy code and I see some opportunities for bugs to be introduced into the system.



To end the whole thing off, if there are two items in the slot, both with a qty of 10 and the warehouse person counts 18 total, I plan to reduce the older stock by 2 to bring the number back to true.

I thought layered inventory would be a nice thing to have, all the little nuances really make it a pain! Thanks for the help!
__________________
Forget Milk!
Gotspy?

www.gotspy.com

Reply With Quote
  #2  
Old July 18th, 2003, 10:58 AM
rkern rkern is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 33 rkern User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
in your select specify the column you want to group on,

SELECT * , slot
FROM inventory
ORDER BY slot
or

SELECT slot, item2, item3
FROM inventory
ORDER BY slot

depending on your db

The GROUP BY clause is closely connected to aggregates, you can only group on things you specifically select

cheers
RK

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Should I use Group By??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway