473,666 Members | 2,039 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 2441
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...@soca l.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_Num ber) 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
2315
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 2085 5 Howard Wilson5
5
3333
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 at least one of each CLUB and at least one of each IFC, but no more than necessary. Example schema and data: CREATE TABLE mDATA ( ID INTEGER, CLUB CHAR(7),
2
2344
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 of the AUTOMATED tags equals YES. I can change the data so that each row whould contain a tag that shows if the EQUIP_TYPE has an AUTOMATED member but that seems wasteful.
17
16372
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 Google Groups for Distinct Count and Count, the Microsoft Help file (which apparently has bad links in Office 2003), and looked at other files, but I can't find the answer. The closest I've been able to get is to create a query to find the...
18
3045
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 only returning one record. She states that with disctinct the query stops as soon as it finds a matching record. Both of us are relative novices in database theory (obviously). Can someone help settle this?
1
14482
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 aggregate function, but there is no reference, at least that I can find anywhere, of how to do this. I have multiple lines fields for which I would like to do a "count distinct", but for simplicity, I am showing an example of only one field. Here is...
6
1391
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 similar to) the desired title entered by the user. The database uses a many to many relationship between tblArtists, tblLINKArtist_Recording and tblRecordings to allow every artist to have many recordings associated with them and every recording to...
1
2323
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 there has been activity In part II I then want to select the most recent effective dated record (if any and whether it existed before this run or was generated by an earlier insert) and sum it with the record for this date
3
2930
by: penny111 | last post by:
Hi, I have created an MS Access database containing the following tables: Crime CrimeCommitted Criminal CriminalOrganization CriminalType HideoutType
1
1986
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 = 'yes' ORDER BY year DESC LIMIT 2, 1"; $result = mysql_query($sql); while($fetched = mysql_fetch_array($result)) { $ceiling = $fetched; } $sql = "SELECT * FROM _current_floats WHERE active = 'yes' AND yearID <= $ceiling ORDER BY yearID...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2773
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 we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.