473,396 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Retrieving last rows from each DISTINCT set

Hi!

Suppose there is a table MarketData and has following data

id--symbol--------date--------------time------price
1-----A--------2007-09-28------09:30:00------37.03
2-----A--------2007-09-28------10:30:00------38.75
3---MSFT----2007-09-28------09:30:00-----44.54
4 --MSFT----2007-09-28------10:00:00-----45.63
5---ABK------2007-09-28-------09:30:00-----63.08
6---ABK------2007-09-28------11:00:00-----53.80


Now what I want to do is that i want to retrieve the last rows of every distinct symbols (order by time desc).


id----symbol------date--------------time------price
2-----A--------2007-09-28------10:30:00-----38.75
4 --MSFT----2007-09-28------10:00:00----45.63
6---ABK------2007-09-28------11:00:00-----53.80

Thank you!!
Sep 29 '07 #1
3 4072
mwasif
802 Expert 512MB
This will work for you
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM (
  2.           SELECT * FROM marketData ORDER BY date DESC, time DESC
  3. ) tmp
  4. GROUP BY symbol
  5. ORDER BY symbol
Sep 29 '07 #2
hey thank you!
that really works....

again thanks...
Sep 29 '07 #3
mwasif
802 Expert 512MB
You are welcome:-)..
Sep 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
6
by: Dean Slindee | last post by:
Does anybody have an actual example of retrieving an Image data type column from a SQL Server table using a dataset (not a datareader)? I would like to see the statements that would move the...
0
by: EastendLad | last post by:
OK guys hope this isnt to below you all but im new to msql and would appreciate some help. I have the following tables forum_frm (ALIAS = F) ########################## # id_frn # title_frm # ...
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
4
by: monomaniac21 | last post by:
hi! is it possible to do the aforementioned query - selecting only distinct in 1 col but retrieving all other cols at the same time. regards marc
1
by: sgCool | last post by:
My data is like Below: id abc def ---- --------- ------------------------------ 1 1.584795 2006-11-04 13:36:06.0 2 1.584795 2006-11-04...
17
by: pbd22 | last post by:
Hi. How does one return a range of rows. I know that "Top 5" will return rows 0 - 5 but, how do I get 6 - 10? thanks
9
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.