Difference between revisions of "Select a record with the latest date"
From SQLZOO
(Created page with "Select a record with the latest date. <div class='ht'> <div class=params>schema:gisq</div> <div> There may be several records with the same date. <h4>There are two steps... (a...") |
|||
| Line 4: | Line 4: | ||
<div> | <div> | ||
There may be several records with the same date. | There may be several records with the same date. | ||
| − | <h4>There are two steps... | + | <h4>There are two steps... <br/> |
| − | (a) Find the latest date | + | (a) Find the latest date <br/> |
| − | (b) Select records with that date | + | (b) Select records with that date <br/> |
| + | |||
With a nested select we can do both of these in one go.</h4> | With a nested select we can do both of these in one go.</h4> | ||
</div> | </div> | ||
Latest revision as of 15:27, 17 July 2012
Select a record with the latest date.
schema:gisq
There may be several records with the same date.
There are two steps...
(a) Find the latest date
(b) Select records with that date
With a nested select we can do both of these in one go.
SELECT * FROM totp WHERE wk= (SELECT MAX(wk) FROM totp)