|
Posted by Erland Sommarskog on 02/18/06 01:13
(uspensky@gmail.com) writes:
> kind of a tough one i think but any help is appreciated. please try to
> stay away from T-SQL...
You want an MDX query instead? :-)
> I have a table with products and closing dates for each of 4 quarters
> and annual for several years back. (Earning_Dates)
> I have another table that has those products with dates and closing
> prices. (undPrices)
>
> i have a third table which has the id for all the products.
>
> I need a query that will look at earning_dates and return the latest 6
> records for each product.
>
> ALSO
>
> a query which will do that as well as return the closing_price at each
> of those 6 dates for each of the products in earning_dates.
I'm sorry, but I can't connect the product in Earning_Dates to the
columns in undprices or products. I could make a guess, but I don't
like guessing, as it lead me to spend time solving the wrong problem.
Also, I'm uncertaing which are the "latest 6 records".
What all this boils down is the standarad recommendation that posts
of this kind should ionclude:
o CREATE TABLE statements for your tables.
o INSERT statements with sample data.
o The desired output, given the sample.
This makes it possible to copy and paste into to Query Analyzer to
develop a tested solution. Also, by providing the desired result,
we get a better idea of what you are really looking for.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|