Counting Transactions

Sep 17, 2007

Hi there,

I have one table, called tblTransactions, which contains records on security market transactions. For each buy and sell order, respectively it contains one dataset with columns Date, Ticker (i.e. the unique identifier of each security), Quantity (positive for buy, negative for sell orders) and Price (at which the trade was executed).

The following SQL query code gives me then the composition of my security portfolio as per any arbitrarily chosen date (here 1/10/2007):


SELECT [tblTransactions].[Ticker], sum([tblTransactions].[Quantity]) AS TotalQuantity
FROM tblTransactions
WHERE [tblTransactions].[Date]<=#1/10/2007#
GROUP BY [tblTransactions].[Ticker]
HAVING sum(tblTransactions.Quantity) >0
ORDER BY [tblTransactions].[Ticker];


For instance, for some trades like the following...


Data --- Ticker --- Quantity --- Price
01/01/07 --- AAA --- 50 --- $50
01/01/07 --- BBB --- 25 --- $75
01/15/07 --- AAA --- 30 --- $60

...it results in the following query results:

01/10/07:
Ticker --- TotalQuantity
AAA --- 50
BBB --- 25

01/20/07:
Ticker --- TotalQuantity
AAA --- 80
BBB --- 25

However, I would like to add a column to this query, which gives me the number of trades for each particular stock. For instance, the query result based on the sample data above should look like follows as per 01/20/07:

Ticker --- TotalQuantity --- NumberOfTrades
AAA --- 80 --- 2
BBB --- 25 --- 1

I have absolutely no idea how to achieve that. I would be very happy for any suggestions.

Best regards,
JapanFreak

View Replies


ADVERTISEMENT

Transactions In Access

Aug 14, 2005

Hi, folks.

I have to write a PHP web front-end to a client-server MS Access applicatin, and I think I've hit a stumbling block.

I use ADOdb as my db abstraction layer, and it has transaction functionality built in. I've tried it with Access, and while according to the output of the code the transaction has worked, I see clearly that it has not worked.

If I insert an intentionally malformed statement as part of the transaction, none of the other queries are rolled back upon the failure of said transaction.

I know this is an Access forum, not a PHP forums, but I've gotten zero response to this post on PHP forums.

Does anyone know if there's a way I can implement transactions for Access via PHP?

Cheers and thanks very much in advance.

Pablo

View 1 Replies View Related

Transactions In Access XP

Nov 23, 2004

I am trying to run a transaction in my databases and I’m having problems with rollback. I have an append query and a delete query that I’m trying to run Just a test I begin the transaction, run the queries and then rollback the transaction. For some reason the rollback isn’t working. Please look at my code and let me know what I’m doing wrong. Are transactions not available in DAO? Also, how do you tell if all records were updated – How do you know when to Rollback?


Sub ArchiveRecords()
Dim db As DAO.Database
Dim qdfArchive As QueryDef
Dim qdfDel As QueryDef
Set db = CurrentDb
Set qdfArchive = db.QueryDefs("qry0201ArchiveLayoffs")
Dim cnn As Connection
Set cnn = CurrentProject.Connection
Set qdfDel = db.QueryDefs("qry0202DelArchiveLayoffs")
cnn.BeginTrans
qdfArchive.Parameters(0) = 1
qdfArchive.ExecuteqdfDel.Parameters(0) = 1
qdfDel.Execute
cnn.RollbackTrans
End Sub

View 1 Replies View Related

SQL For Financial Summary From Transactions

Oct 20, 2005

I am working on a financial integration system that receives lists of financial journal transactions from several accounting packages.

I import and sumarise the transactions and end up with a transactions table like the one below. I now want to produce an Accounts summary (by period) table. I am trying to figure out how to do this just using SQL.

I do not want to use record by record VB because it is slow and I have a million+ records.

Can anybody help ?

Transactions Table (input)

Account Period Amount
1011100
1015 100


Account Summary (desired output)

Account Period Opening Movement Closing
101 10100100
10121000100
10131000100
10141000100
1015100100200

PS I need to run on Access and SQL Server

View 1 Replies View Related

Need Sample Database For Stock Transactions

Jan 28, 2008

Hi,

I'm in over my head with something I've been asked to do at work as my access skills are pretty basic.

I need a sample database containing PRODUCTS and SUPPLIERS, that lets you book IN stock received from the supplier (and adds to the stock level) and lets you book OUT stock issued to staff (and reduces the stock level)

I'll have a go at reorder levels, form design, stuff like that myself, but I'm having trouble with these very basic requirements.

Does anyone know of a sample database that I can download to learn some of this from?

View 2 Replies View Related

General :: Creating Distinct Transactions

Jun 24, 2013

I need to create distinct transactions for each invoice, so that if the static data changes, such as rates of charge, it will not automatically update any history, where a historic rate has been charged.My current thinking is that I create a table and effectively archive all invoices that have been created, as they are produced.

View 4 Replies View Related

Running Calculation Based On Previous Transactions

Jul 12, 2005

I am building an application for a small clinic. In the interests of good database design, I don't want to be storing numbers that are derived by calculation.

A patient with insurance will have a deductable that will be entered into a field on their first (ms access) transaction form.

A calculation will put the remaining deductable into another field. No problem.
However, the NEXT visit has to look back to find previous transaction records, again perform the initial calculation and then perform another for this transaction, and again the next time and the next until the deductable reaches zero.

Additionally, since I'm not storing these values, if I pull up an old transaction form, that form has to re-perform the calculation ONLY on transactions from that date and earlier. It must not reflect visits that took place later.

So, this field must query tblTransactions, filtered by the name of the patient (a combo box called tblTransactions.Patient_Name that looks at tblContacts), the transaction date/time (stored in two date/time fields, cleverly named tblTransactions.Date and tblTransactions.Time), and the total deductable value stored in a field called tblTransactions.Deductable.

As someone who has never coded anything more complicated than DOS batch files, I'm at somewhat of a loss as to how to go about this.

Any assistance, code-wise and which Property value to put it in would be MOST appreciated.

View 1 Replies View Related

Making Transactions With Multiple Products (Diagram Inside)

Mar 21, 2008

Hey people, hows it going? Quick question

I am creating an EPOS system for a bookstore and I have a many to many relationship between the transactions table (tbl_transactions) and the products table (tbl_products) using a link table (tbl_linktblproductstransac). The below diagram shows what i mean below:

http://img512.imageshack.us/img512/3246/relationnshipswd9.jpg

I made it many to many because 1 transaction can have many products on it and 1 product can be on many transactions.

Now what I need to know is how will i make records with more than one product on one transaction (in the table itself or in a transaction form). I would really appreciate if someone could help. Thanks :) and have a good Easter

View 2 Replies View Related

Show Certain Records (eg: Unpaid Transactions) As A Different Colour In A Listbox

Nov 30, 2006

i think this post may benefit others because to me it seems like a good idea,

a listbox displays 2 fields from your database

job table
id (autonumber primary key)
pay (text)

here are 5 records,
1,paid
2,paid
3,paid
4,unpaid
5,unpaid

if you make a form with a listbox showin these records..

is there a way to make the unpaid records appear as red?

View 9 Replies View Related

Modules & VBA :: Calculate Median Value For Group Of Transactions Within The Same Industry?

Oct 15, 2013

I am using the code below to evaluate values for each transaction to determine the median:

Function MedianF(pTable As String, pfield As String, pgroup As String) As Single
'*******************************************
'Purpose: Return median value from a recordset
'Inputs: ? medianF("Values", "Industry") <enter>
'Output: results are currently incorrect
'*******************************************
Dim rs As Recordset
Dim strSQL As String

[code]....

The code generates median results based on the value but not the correct ones, as I check results in Excel using the Median function. I need to see the median for the transactions within the same industry and I do not know how to do that . Below are some sample transactions including the Industry, Value, mymedian (which the current results based on my code) and the expected median result (which I calculated in Excel based solely on the transactions listed here). Note that mymedian results listed in the 3rd column are determined using the complete data set (over 2000 transactions). I only included a few sample transactions below to show that I am currently getting 2 different median results: 44.62 and 50.82. Also be aware that I do not want to evaluate any zero value transactions, which I believe I am handling in the strSQL line above where I indicate <>0 . I need to see a Median result for each industry and the result should be the same for all transactions within the same industry.

Industry Value mymedian Expected Median
Aerospace 18.01 50.82 40.45
Aerospace 53.02 50.82 40.45
Aerospace 109.18 50.82 40.45
Aerospace 61.54 44.62 40.45

[code]....

This is how I am passing the values from the query to the module, passing the value of Period2 if Period 1 = 0, else passing Period1:

mymedian: IIf([Period1]=0, medianF("qry_My_Query","Period2","Classification_I ndustry"), medianF("qry_My_Query","Period1","Classification_I ndustry"))

View 14 Replies View Related

Tables :: Relating Transactions With Rate Master Table

Jan 28, 2013

I am using Access 2007 and have inherited a database. It has linked tables of Excel spreadsheets that are information extracted from our main system. The user wants developing a much faster and customized approach to billing the customer based on payroll related information.

There is a table of payroll billing transactions and it has the following record lay-out,

job_num, employee number, employee name, union group, rank, regular hours, overtime hours, other hours, trans_date, seq_num

6430, 2301, john doe, 1, F, 8.0, 0.0, 0.0, 12/01/2012, 254333

On December 1st John Doe worked 8.0 regular hours as a pipefitter foreman on job number 6430 and this is record (sequence) number 254333.

There is another table that defines the union group. I am not concerned with this information at this time. The seq_num is a sequentially and uniquely assigned number given to each billing record in the main system.

There is also a Rate Master table and it has the following record layout,

job_num, union group, rank, regular_billing_rate, overtime_billing_rate, other_billing_rate

I am struggling as to how to relate these two tables so that I can develop some queries from it.

View 2 Replies View Related

Queries :: Time Query - Show Transactions For Particular Session

Jul 20, 2015

I have a pop up reports tied to my form so the usere can press the see list report of all the equipment they just scanned in or out of the building. I am useing the Date/Time data type (General Date) What I would like to get out of the query is when the user clicks the button it will show all entries from the time right before the button is pressed AND through 5 minutes earlier. (That would be the time that the user would of started scanning the equipment.

This is my current criteria : Between Now() And Date()

This is returning all transactions for the day. I really only want all transactions for that session.

View 3 Replies View Related

Queries :: Keeping Records Of GST Transactions - How To Do Calculations In Query

Apr 5, 2013

I am trying to keep records of GST transactions.

I have a problem in figuring out how to do calculations in a query.

How to have the calculation in the attached MDB and Document for field #105_SubTotal and the field #115_PaymentEnclosed.

View 7 Replies View Related

General :: Calculating Stock Level For Spare Parts From Transactions

Jun 19, 2012

I am trying to calculate the stock level for my spareparts. I am aware of that I am not to update the stock level in my table but calculate the total from the transactions.

View 9 Replies View Related

Counting Of Cases And Counting No Records

Jan 26, 2007

I have a report due the first of each week in which I need the cases open and cases closed for the previous week, the week two weeks prior and the 2007 and 2006 year to date on two different types of cases. I have a case management table with a field for Type of Case, date assigned and date closed that I uses in my queries. Presently I have two query, one that generates only Type 1 cases from the Case Management Table and another for Type 2. I then use the Type 1 Query in another query that limits the results for Type 1 cases to those opened last week, one for those open two weeks ago, one for 2006 YTD and one for 2007 YTD. In these 4 queries I have one field [Type of Cases] and I have the query count. I then do this for Type 2 cases and then go through the whole process to do Closed Cases. All my queries have criteria to automatically filter the dates to the time periods mentioned above. I then have one report query that I put all the number in for my report. This query has 16 fields with the numbers for each period, last week open and closed, 2 weeks open and closed, etc. I then generated a report that takes these numbers from my report query and puts it in a report format automatically. As you can imagine this takes some time to go through each query to generate these numbers, so I was wondering how I may do this differently. Also, I have experienced a problem when a field produces no records I get a blank sceen with nothing under the Count of column and get the same thing for my report. How can I fix this.

View 1 Replies View Related

Queries :: Adding Sequence Number To Transactions Based On Date And Unique ID

Jul 29, 2014

I have a set of transactions with a Unique ID field and a date. I want to add a field based that gives me the sequence of events for each Unique ID in order of when it happened.

For example, if customer X has 6 transactions, the sequence field would have a number (1-6) in each record that corresponds to the order in which those transactions occurred. The first transaction would have the number 1, the second would have the number 2 and so on.

View 3 Replies View Related

Queries :: Products Form - Listbox To Show Recent Inventory Transactions

Apr 3, 2014

I have a products form, we are a manufacturing company, with a listbox to show recent inventory transactions. This is based on a query which shows all transactions with the current part id, and that all works well and fine.

The problem is, I would like to limit this query to show only the last 10 transactions in the listbox and not make it editable, ie not enabled. I set the show only in query design view to 10 and it says in the sql statement select top 10, however, the listbox consistently shows all related records. What am I missing?

View 8 Replies View Related

Modules & VBA :: Read CSV Transaction File Line By Line And Add Correct Transactions To Access Table

Nov 29, 2014

I have a module which reads a CSV transaction file line by line and adds the correct transactions to an access table and places the wrong ones in a logfile.Now some transactions are rejected twice there is even one rejected six times. Whereas one wrong transaction is processed only once. I am certainly overlooking something obvious in the logic but what. Here is the relevant code.

Code:

Function ImportCSVForConfederation(inputCSV, ORG)
Dim TNO As Integer, TACT As Integer, TABLE As String, TLINE As String, I As Integer, J As Integer, K As Integer
Dim FLD1 As String, FLD2 As String, FLD3 As String, FLD4 As String, LogFile As String, LogPath As String
Dim Lim As String, ITNO As Integer

[code]....

View 8 Replies View Related

Counting

May 13, 2005

i am trying to count the number of records based in a query

can some one send me in the right direction

View 2 Replies View Related

Counting

Feb 8, 2006

I have a database where there are numerous fields but they all only have one three values Y, N, N/A.

how do i get something similar to Excels "countif" function to summarise the totals of Y's N's N/A's inach field ?

Thanks

View 1 Replies View Related

Counting

Feb 8, 2006

I have a database where there are numerous fields but they all only have one three values Y, N, N/A.

how do i get something similar to Excels "countif" function to summarise the totals of Y's N's N/A's in each field ?

Thanks

View 4 Replies View Related

Counting

Jan 26, 2007

How can I count the number of times an employee shows up on a report. The final result would be:

Employee 1: Reader1
Employee 1: Reader2
Employee 1: Reader3
Employee 1: Reader4

If an employee shows on a report 4 times, I need it to look like the example above in sequential order, not just a total.

Thanks for your help.

View 1 Replies View Related

Counting Down!

Jan 10, 2006

Hi

I have a form which displays which products are on sale but I want it to count stcok orders down, i.e. if there are 10 stock and someone orders 1 I want the system to automatically recognise that there are only now 9 in stock, any ideas? Help really would be appreciated!

Thanks

B

View 4 Replies View Related

Counting

Apr 18, 2007

Hello,

I have a form called feedback which has three columns and each cell in a column has a combo box that holds (Yes/No/Empty), and I want to count each column's value for example let's supposed that:


feeback number: Column 1 (Are You happy) - Column 2 (Are you sad) - Column 3 (Are you hungry)
1 : Yes - No - Yes
2 : Yes - Yes - Yes
3 : No - No - Yes
4 : empty - No - yes

Counting: the next step is that I want to count:

values in Column 1, where number of Yes =2 , and number of No=1 the stum of Yes + No = 3 and empty = 1
values in Column 2, where number of Yes =1 , and number of No=3 the stum of Yes + No = 4 and empty = 0
values in Column 3, where number of Yes =4 , and number of No=0 the stum of Yes + No = 4 and empty = 0


So, how can I apply this concept in MS ACCESS (2000-2003).

I am waiting for you kindly reply.

View 1 Replies View Related

Counting Summary

May 16, 2005

hi
i have a number of query's (Current memberships, out of date memberships etc) all via a certain area/town.

i am trying to find out total figures (how many members how many non members, how many in certain area/town. these need to be updated continuoulsy.

do not no how to approach i ahve looked at the sigma sign and played with no luck.

should i be looking at another query for totaling or un update qurey, sorry very lost, would like this information also displayed on my record form.

searched all weekend with no luck any ideas.

View 2 Replies View Related

*?? Counting Values In The DB *??

Feb 2, 2006

Hi I have a table that looks like this:

Col1 Col2 Col3 Col4 Col5 Col6
1 A B C D E
2 A B C D F
3 A B C G H
4 A B J K L
5 A D M N P


Does anyone know how I can run an SQL query to count how many letters there are For example : 5 A's 4 B's 3 D's Etc

Cheers,
bikeboardsurf

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved