I am relatively inexperienced with SQL, and I am trying to learn how
to analyze some data with it.
I have a table with the following information.
COMPANY ID , DATE, MarektValue
I would like to select the largest 100 marketvalues for each date in
my table. How can I do this efficiently in MySql.
In Microsoft Access , I can run something like this, but it is
extremely slow:
SELECT Company ID, Date, MarketValue
FROM Table1 RIGHT JOIN Dates ON Table1.Date = Dates.Date
WHERE (((Marketvalue) In (Select Top 100 [marketvalue] from Table1
where [Date] = [dates].[Date] Order by date, MarketValue Desc)));
I know that the LIMIT function in mySql will get 100 rows if i am
looking at one specific year. but I cant seem to get it to take the
100 largest marketvalues every year.
Thanks in advance for any assistance!
to analyze some data with it.
I have a table with the following information.
COMPANY ID , DATE, MarektValue
I would like to select the largest 100 marketvalues for each date in
my table. How can I do this efficiently in MySql.
In Microsoft Access , I can run something like this, but it is
extremely slow:
SELECT Company ID, Date, MarketValue
FROM Table1 RIGHT JOIN Dates ON Table1.Date = Dates.Date
WHERE (((Marketvalue) In (Select Top 100 [marketvalue] from Table1
where [Date] = [dates].[Date] Order by date, MarketValue Desc)));
I know that the LIMIT function in mySql will get 100 rows if i am
looking at one specific year. but I cant seem to get it to take the
100 largest marketvalues every year.
Thanks in advance for any assistance!
Comment