473,386 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Warehouse Database

Hi, a colleague asked me to see if it's possible to create a warehouse database for him, so things will go faster and more efficient on his end. (yes, in the midst of my annual database project...) I tried a few things, got stuck, tried to look for information on the web but to no avail.

Anyway, here is the scenario.
3 main fields from tblMain:
Index - P.Key
Part - name of the product
Location - location of the product stored in the warehouse
Qty - quantity of the product available in that location

I need a subtotal of each record instead of the overall total from
Expand|Select|Wrap|Line Numbers
  1. Sum(Qty)
So here's what I did.
Query1
Expand|Select|Wrap|Line Numbers
  1. SELECT tblMain.*, tblMain_1.*, IIf([tblMain.Location]>[tblMain_1.Location],[tblMain_1.Qty],IIf([tblMain.Location]=[tblMain_1.Location],[tblMain.Qty],0)) AS IF
  2. FROM tblMain, tblMain AS tblMain_1;
Query2
Expand|Select|Wrap|Line Numbers
  1. SELECT query1.tblMain.Part, query1.tblMain.Qty, Sum(query1.IF) AS Cumulative
  2. FROM query1
  3. GROUP BY query1.tblMain.Part, query1.tblMain.Qty;
This works fine, if what I want is just to show the cumulative subtotal of every record irregardless of Location and Part. However, I need to differentiate by Part. Note that Cumulative is calculative field.

Example:
Part Location Qty Cumulative
X A1 3 3
X A2 4 7
X A3 10 17
Z B1 11 11 ------ here the Qty for Z does not add up with Qty for X
Z B2 20 31
Z B3 25 56

And here is what I get from what I did:
Part Location Qty Cumulative
X A1 3 3
X A2 4 7
X A3 10 17
Z B1 11 28 ------ here the Qty for Z continue adding up with Qty for X
Z B2 20 48
Z B3 25 73

The usage of this database will be:
1) user set criteria for qty of part to be taken out.
2) database shows user the records where Cumulative < Qty_Criteria
3) then user follows the database's results to proceed to take out the parts.

Disclaimer: The query idea, I got it from another web user. The idea is not mine. I'm just a noob. :)
Aug 27 '08 #1
1 2821
aas4mis
97
Where did you get tblMain_1 from? A simple query for 1 table for sum of a part would be "SELECT part, sum(qty) FROM tblMain GROUP BY part;". If you want individual locations you need to do a seperate query, the GROUP BY negates individual records.
Sep 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Robert Brewer | last post by:
def warehouse(stock, factory=None): """warehouse(stock, factory=None) -> iavailable, iremainder. Iterate over stock, yielding each value. Once the 'stock' sequence is exhausted, the factory...
0
by: Aashish | last post by:
Hi, I am currently working on building a real-time data mart. Am using DTS as the ETL tool and MS SQL 2000 as the database. The current infrastructure includes 2 4 Proc (1GHz) Xeon based servers,...
2
by: ScottH | last post by:
I am running DB2 7.2 FP8e with the Data Warehouse Center (using Tivoli Data Warehouse). Everything was humming along fine. I defragged all my drives without bringing DB2 down (should have known...
1
by: M. Krafick | last post by:
I just took over a v8.1 database that is at Fixpack 2. I know that need to apply a later fixpack, probably FP6. My question is how does this affect Data Warehouse Center? I have heard that if...
0
by: DB2 DBA wanted | last post by:
Maines Paper & Food Service is a $2 billion/yr food distribution company with 9 distribution centers in the US. We are currently interviewing for the position detailed below. Relocation to...
0
by: mghale | last post by:
I am receiving this error every time I try to access the Data Warehouse Center Tutorial database TBC_MD. DWC01007E Logon Failed. The database specified by the user does not match the database...
0
by: vijaykumars | last post by:
I am extracting data from Oracle9i database to Tivoli Data warehouse(DB2) using WEP (ETL) and have following problem: The Rim_Extract(AMX - Tivoli Data Warehouse) step has stopped with the...
0
by: avbaby | last post by:
hi, i am using data warehouse center as an ETL. I have a remote database and a local database. i have to extract data from remote and put it in local database. remote database consists of complete...
7
by: Karol R | last post by:
Can anyone please explain me main differences between relational DB and warehouse (Point me to web site) ? Apart from theoretical differences I would like to know how Warehouse DB is updated ?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.