abesimpson
Active Member
- Joined
- May 3, 2003
- Messages
- 435
I know similar questions have been asked and answered, but I can't figure out the answers to meet my requirements so hopefully someone can help me.
I have a database which consists of several stock tickers sorted on "Date" and and calculated value ("ABS"). What I require is to be able to generate a "Ranking Value" from the ABS value, where the highest ABS = 1, next highest =2, etc. for any particular date group, then starts again. I currently create the ranking in Excel and re-import the results into Access. I have almost reached the 65.5k record Excel limit and now need to do all the work in Access
The code I use to generate my un-ranked table is as follows:
INSERT INTO [Ranking ABS Access] ( Ticker, [Date/Time], Equationtype, Calcgain, ABS )
SELECT [Main program walkforward explore table].Ticker, [Main program walkforward explore table].[Date/Time], [Main program walkforward explore table].Equationtype, [Main program walkforward explore table].Calcgain, Abs([PositionScore]) AS ABS
FROM [Main program walkforward explore table]
ORDER BY [Main program walkforward explore table].[Date/Time], Abs([PositionScore]) DESC;
I have found the following code which by description does what I need (though it will take someone much smarter than I am to translate it to my needs) albeit for a differently structured database:
select a.Dept, a.Subdept, a.Amount, count(*) as rank
from
(
select Dept, Subdept, Amount
from joe
group by Dept, Subdept, Amount
) as a
inner join
(
select Dept, Subdept, Amount
from joe
group by Dept, Subdept, Amount
) as b on a.Dept = b.Dept and a.Amount <= b.Amount
group by a.Dept, a.Subdept, a.Amount
order by a.Dept, a.Subdept, count(*)
Any and all help/directions/suggestions/and even questions will be greatly appreciated.
Abe
I have a database which consists of several stock tickers sorted on "Date" and and calculated value ("ABS"). What I require is to be able to generate a "Ranking Value" from the ABS value, where the highest ABS = 1, next highest =2, etc. for any particular date group, then starts again. I currently create the ranking in Excel and re-import the results into Access. I have almost reached the 65.5k record Excel limit and now need to do all the work in Access
The code I use to generate my un-ranked table is as follows:
INSERT INTO [Ranking ABS Access] ( Ticker, [Date/Time], Equationtype, Calcgain, ABS )
SELECT [Main program walkforward explore table].Ticker, [Main program walkforward explore table].[Date/Time], [Main program walkforward explore table].Equationtype, [Main program walkforward explore table].Calcgain, Abs([PositionScore]) AS ABS
FROM [Main program walkforward explore table]
ORDER BY [Main program walkforward explore table].[Date/Time], Abs([PositionScore]) DESC;
I have found the following code which by description does what I need (though it will take someone much smarter than I am to translate it to my needs) albeit for a differently structured database:
select a.Dept, a.Subdept, a.Amount, count(*) as rank
from
(
select Dept, Subdept, Amount
from joe
group by Dept, Subdept, Amount
) as a
inner join
(
select Dept, Subdept, Amount
from joe
group by Dept, Subdept, Amount
) as b on a.Dept = b.Dept and a.Amount <= b.Amount
group by a.Dept, a.Subdept, a.Amount
order by a.Dept, a.Subdept, count(*)
Any and all help/directions/suggestions/and even questions will be greatly appreciated.
Abe