Excel/access question

thiedeni19

New Member
Joined
Nov 12, 2018
Messages
2
Hello

I need a help manipulating data on a spreadsheet. The spreadsheets columns are buy or sell, ticker, price, trade date, execution time. The rows are filled in with varying trade information, with either a buy or sell. I'm trying to identify all trades that took place on the same day and time that have the same ticker, but have different trade type (sell or buy), for instance, I'm interested in pulling a list that shows all the tickers of positions that had buy and sells on the same day at the same time, and I don't care about the rest of the rows. I am familiar with Excel or access, so whichever one would be easier, desperate need of help getting rid of this headache!!
Thanks!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
In Access, I am envisioning a Group By Query.

Maybe something like this where the tablename is Ticker

Code:
SELECT Ticker.tDate, Ticker.tTime, Ticker.Ticker, Ticker.BuySell, Ticker.Price
FROM Ticker
GROUP BY Ticker.tDate, Ticker.tTime, Ticker.Ticker, Ticker.BuySell, Ticker.Price;
 
Upvote 0
In Excel or Access,
Code:
SELECT D.BuySell, D.Ticker, D.Price, D.TradeDate, D.ExecutionTime
FROM YourTable D, (SELECT B.Ticker, B.TradeDate, B.ExecutionTime
FROM (SELECT DISTINCT A.BuySell, A.Ticker, A.TradeDate, A.ExecutionTime
FROM YourTable A) B
GROUP BY B.Ticker, B.TradeDate, B.ExecutionTime
HAVING (Count(*)>1)) C
WHERE C.Ticker = D.Ticker AND C.TradeDate = D.TradeDate AND C.ExecutionTime = D.ExecutionTime
 
Upvote 0
In Excel or Access,
Code:
SELECT D.BuySell, D.Ticker, D.Price, D.TradeDate, D.ExecutionTime
FROM YourTable D, (SELECT B.Ticker, B.TradeDate, B.ExecutionTime
FROM (SELECT DISTINCT A.BuySell, A.Ticker, A.TradeDate, A.ExecutionTime
FROM YourTable A) B
GROUP BY B.Ticker, B.TradeDate, B.ExecutionTime
HAVING (Count(*)>1)) C
WHERE C.Ticker = D.Ticker AND C.TradeDate = D.TradeDate AND C.ExecutionTime = D.ExecutionTime


When I try this, it's asking to 'Enter Parameter Value' for A.Trade Date, what would I enter for that?
 
Upvote 0
I think the fix is simply to edit the SQL to have all field names identical in both the source table & the SQL.

For example, field name [TradeDate] has no space in the SQL. So should be the same in the source table. Or,
if there is to be a space in the field name in the source table, change the SQL to have a space, viz [Trade Date]

OK?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top