sql - How to get most recent data? -


i have table 3 pieces of data, facilityname, datelastverified, & intensity. want able pull records recent datelastverified. when datelastverified same, want select record highest intensity.

|facilityname                                   | datelastverified | intensity |nemours/alfred i. dupont hospital children | 2014-03-01       | 16 |boston children's hospital                     | 2015-11-29       | 6 |boston children's hospital                     | 2017-04-01       | 3 |tufts medical center                           | 2017-04-01       | 3 |tufts medical center                           | 2017-04-01       | 6 

so above table i'd want return second entry boston children's hospital , second entry tufts medical center. how write this?

i want able pull records recent datelastverified. when datelastverified same, want select record highest intensity.

based on description, can 1 record using order by , fetch first 1 row only:

select t.* t order datelastverified desc, intensity desc offset 0 row fetch first 1 row only; 

or sql server:

select top 1 t.* t order datelastverified desc, intensity desc; 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -