473,507 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get only Max of each distinct?

Hello,

I have a table

ItemID Version

12 1.0
12 1.1
12 2.0
13 2.0
13 1.0
14 1.0
15 1.0
15 5.0
15 2.1

How do I write a Select query to get me all distinct item IDs, whichm
are of the latest version?

Like this:

ItemID Version
12 2.0
13 2.0
14 1.0
15 2.1

Any help would be appreciated.

Thanks

Nov 7 '07 #1
2 2431
su******@gmail.com wrote:
I have a table

ItemID Version

12 1.0
12 1.1
12 2.0
13 2.0
13 1.0
14 1.0
15 1.0
15 5.0
I assume 5.0 is a typo for 2.0
15 2.1

How do I write a Select query to get me all distinct item IDs, whichm
are of the latest version?

Like this:

ItemID Version
12 2.0
13 2.0
14 1.0
15 2.1
This smells like homework. Look up MAX() and GROUP BY.
Nov 7 '07 #2
On Nov 7, 10:10 am, Ed Murphy <emurph...@socal.rr.comwrote:
sunil...@gmail.com wrote:
I have a table
ItemID Version
12 1.0
12 1.1
12 2.0
13 2.0
13 1.0
14 1.0
15 1.0
15 5.0

I assume 5.0 is a typo for 2.0
Got it, actually it was pretty simple, was trying it incorrectly
earlier !

SELECT MAX(Version_Number) AS Maxim, ItemId
FROM tblItems
GROUP BY ItemId

Thanks
15 2.1
>
How do I write a Select query to get me all distinct item IDs, whichm
are of the latest version?
Like this:
ItemID Version
12 2.0
13 2.0
14 1.0
15 2.1

This smells like homework. Look up MAX() and GROUP BY.

Nov 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2299
by: Navin | last post by:
hi, guys i have query which given below output given below manager personlevel person name 2085 1 Howard Wilson1 2085 2 Howard Wilson2 2085 3 Howard Wilson3 2085 4 Howard Wilson4...
5
3324
by: Ross Presser | last post by:
The purpose, as you can probably guess, is to produce a set of sample documents from a large document run. The data row has a CLUB column and an IFC column; I want a set of samples that contains...
2
2332
by: Bill Sneddon | last post by:
I am using the for-each below to build a table where the header is a unique nonblank EQUIP_TYPE. This works well. What I would like to do is not execute the for loop on on EQUIP_TYPE unless one...
17
16350
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched...
18
3032
by: mathilda | last post by:
My boss has been adamant that SELECT DISTINCT is a faster query than SELECT all other factors being equal. I disagree. We are linking an Access front end to a SQL Server back end and normally are...
1
14466
by: nfrodsham | last post by:
In Microsoft's help literature, it states: "You can filter out non-unique rows by using the DISTINCT option of an aggregate function" I am trying to do this in Access 2003 with the COUNT...
6
1387
by: andrewrubie | last post by:
Hi All, I have built a search page(asp) in dreamweaver for a friend with a used records store and website. The results page lists all recordings their database(ms access 2002) holds with(or...
1
2310
by: new | last post by:
I am building an effective dated file that shows results to date. In part 1 of the select I I process a larges set of input and genrate records for each date in the processing period for which...
3
2914
by: penny111 | last post by:
Hi, I have created an MS Access database containing the following tables: Crime CrimeCommitted Criminal CriminalOrganization CriminalType HideoutType
1
1963
by: digidave | last post by:
I am keenly aware that my coding skills are extremely noob but please indulge me a second.. Take a look at these queries.. $sql = "SELECT DISTINCT year FROM _current_floats_config WHERE active =...
0
7319
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
7376
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...
1
7031
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
7485
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...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.