473,386 Members | 2,078 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.

Direct access to records via timestamp

Let us consider the example of a stock system. Suppose that in each
transaction, cumulative totals of sales are kept. Now to find the
cumulative sales at any time a composite index of stockcode and transaction
timestamp could be stored. To access the index a composite key of stock
code and timestamp (for the time at which we want to know the stock level)
could be used to access the index. In all likelyhood there was no
transaction at exactly that time. So we need to back up the index to the
previous record. If there is no previous record, or the previous record has
a different stock code then we know that the cumulative sales at that time
is zero.

How do I do this with MS Sql server?

Looking forward to your replies.

Tony
Jul 20 '05 #1
2 2910
Are you using MSSQL7 or 2000?

"news.inspire.net.nz" <to***@maxnet.co.nz> wrote in message news:<fS*****************@news02.tsnz.net>...
Let us consider the example of a stock system. Suppose that in each
transaction, cumulative totals of sales are kept. Now to find the
cumulative sales at any time a composite index of stockcode and transaction
timestamp could be stored. To access the index a composite key of stock
code and timestamp (for the time at which we want to know the stock level)
could be used to access the index. In all likelyhood there was no
transaction at exactly that time. So we need to back up the index to the
previous record. If there is no previous record, or the previous record has
a different stock code then we know that the cumulative sales at that time
is zero.

How do I do this with MS Sql server?

Looking forward to your replies.

Tony

Jul 20 '05 #2

"news.inspire.net.nz" <to***@maxnet.co.nz> wrote in message
news:fS*****************@news02.tsnz.net...
Let us consider the example of a stock system. Suppose that in each
transaction, cumulative totals of sales are kept. Now to find the
cumulative sales at any time a composite index of stockcode and transaction timestamp could be stored. To access the index a composite key of stock
code and timestamp (for the time at which we want to know the stock level)
could be used to access the index. In all likelyhood there was no
transaction at exactly that time. So we need to back up the index to the
previous record. If there is no previous record, or the previous record has a different stock code then we know that the cumulative sales at that time
is zero.

How do I do this with MS Sql server?

Looking forward to your replies.

Tony


I don't really follow your narrative - you may want to consider posting
sample DDL to illustrate your issue. Without more information I don't know
exactly what you're looking for, but the easiest way to find cumulative
sales/shipments for a given period of time would probably be to get the sum
of all sales/shipments quantities between two points in time:

SELECT SUM(QuantityShipped)
FROM dbo.Orders
WHERE PartNumber = 1234
AND ShippedDate BETWEEN '20040101' AND '20040331'

This is an artificially simple example of course, and may not be what you're
looking for at all - I'm just guessing.

Simon
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: news.inspire.net.nz | last post by:
Let us consider the example of a stock system. Suppose that in each transaction, cumulative totals of sales are kept. Now to find the cumulative sales at any time a composite index of stockcode...
0
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Question how do you test stored...
9
by: Paradigm | last post by:
I am using an Access2K front end to a MYSQL database. If I enter a new record in a continuous form the record appears as #deleted as soon as I move to a different record in the form until I requery...
6
by: fumanchu | last post by:
I've got to let end users (really just one person) load billing batch files into a third party app table. They need to specify the billing cycle name, the batch name, and the input file name and...
12
by: Mike | last post by:
I have an Access DB that I upsized to a SQL server DB. The tables that I upsized I can't seem to modify. I wanted to insert some data into the table and I am getting the following error: ...
2
by: NTPT | last post by:
I have this table content (id int8,owner int8,position int8,timestamp int8,description text,batch int8) Table is inserted/deleted frequently, 'id' is almoust random. I insert to the...
1
by: gordon.dtr | last post by:
Hi, Has anyone had this problem ? I am using MySQL ODBC 3.51 Driver, with MS Access 2003 and MySQL 4.1.11 standard log. I created my tables in MS Access, then exported them via ODBC to an...
2
by: David | last post by:
Hi, Has anyone had this problem ? I am using MySQL ODBC 3.51 Driver, with MS Access 2003 and MySQL 4.1.11 standard log. I created my tables in MS Access, then exported them via ODBC to an...
5
by: pnjones | last post by:
I am getting the write conflicit when 2 users access the same record the first one to save is allowed but the second user gets the message Write conflicit with the save option greyed out. I have...
1
MMcCarthy
by: MMcCarthy | last post by:
Access has a number of built-in functions which can be generally used in queries or VBA code. Some of the more common ones are: Note: anything in square brackets is optional Date Functions ...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.