简体   繁体   中英

Select all values of a specific column associated with the max value of another column

I want to pull data from my table.

  line          Entryid
  hello           1
  world           1
  this            1
  is              1
  hello           2
  again           2
  world           2

I want to select all the information associated with Entryid 2. Note i cannot say WHERE Project id = 2. I need something like where MAX(Entryid). So the information pulled will be hello again world

You can do what you want using join or a subquery:

select t.*
from t
where t.entryid = (select max(t2.entryid) from t t2);

You can use a sub query. Select * From yourTable Where Entryid = (Select max (Entryid) From yourTable)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM