473,245 Members | 1,311 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,245 software developers and data experts.

Selecting a different field from a group.

Hi

Hope you can help, been racking my brains on this.

How can I pick a field from a group, based on the order of another field in the group? Not sure if that explains it so..

I have a table

RowID (Int, ID)
ProductCode (Varchar)
CreatedDate (DateTime)

Basically, I want the RowID based on the most recent CreatedDate within each ProductCode.

So, I can do this..

SELECT ProductCode, MAX(CreateDate)
FROM Table
GROUP BY ProductCode

That shows me the highest date on each product, but I want to know what the RowID of that record is?

How can it be done??

Please help
Oct 4 '06 #1
1 1336
Will this work?

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM Table t1
  2. WHERE CreateDate = (SELECT MAX(CreateDate) FROM Table t2 WHERE t1.ProductCode = t2.ProductCode)
  3. ORDER BY ProductCode
Oct 5 '06 #2

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

Similar topics

2
by: John | last post by:
Hello, I have a table called BUILDREQUESTS which I want to select from, depending on the project ID of each record. The Project ID field is indexed. (A) This query runs almost instantly: ...
4
by: manning_news | last post by:
Using SQL2000. How do I format my select statement to choose one out of 24 different tables? Each table is slightly different and I was hoping I could use one select statement and format it...
2
by: Rene | last post by:
I have a master "attendance" report that also has two "attendance" sub-reports...each collecting data from a different group...and totaling those present at the end. I chose sub-reports because...
8
by: Henrik Larsson | last post by:
Hi, I need help with selecting the following rows from a table looking like this: ID IP Query 1 -> 1 2.2.2.2 (ie first IP 1 1.1.1.1 <- Query 2 for each...
6
by: aaj | last post by:
Hi all I use a data adapter to read numerous tables in to a dataset. The dataset holds tables which in turn holds full details of the records i.e. keys, extra colums etc.. In some cases I...
7
by: SHPsalm139 | last post by:
I'm working on a school application. I have a form where the user selects the marking period (1, 2, 3 or 4). That ties in to the "marking_period" field in a table. If the user indicates, for...
4
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it...
5
by: =?Utf-8?B?U3RldmUgSGFwcA==?= | last post by:
Am I missing something? Selecting the discussion group for posting questions is much more difficult than it should be. I have to scan through the entire list every time ... there appears to be no...
5
by: kwartz | last post by:
Can somebody please help me with a select statement for selecting duplicate records with one different field . I have 3 tables: A, B and C A has 2 fields I ---- primary key m B
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.