?
Solved

SQL Select Statement

Posted on 2008-11-03
3
Medium Priority
?
206 Views
Last Modified: 2010-03-20
Hi,

I have a table which contains prices for assets. The asset is not priced everday. All I need to do is get the latest price for all assets held in the table..?

Table example:

Asset                         Price Date  (UK Dates)                Price
A                                03/11/2008                                  4
A                                01/01/2008                                  5
A                                01/07/2007                                  6
B                                01/02/2008                                  7  
B                                01/01/2005                                  7
B                                01/07/2004                                  8  
C                                01/07/2004                                  18  

The SQL should return...
A                                03/11/2008                                  4
B                                01/02/2008                                  7  
C                                01/07/2004                                  18  

Thanks in advance...
0
Comment
Question by:ISC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 22866042
you mean:
SELECT t.*
  FROM yourtable t
 WHERE t.Price_Date = (SELECT MAX(i.price_date) FROM yourtable i WHERE i.Asset = t.Asset )

Open in new window

0
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 22866044
select distinct asset,price,date from table t1order by price desc.
0
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 22866052
sorry mine is wrong.ignore that one.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question