Teradata - How can I extract all rows of a partition using the qualify statement? -
i have data in table looks following
username loaddate -------- ---------- gittes1 2016-01-25 gittes1 2016-01-25 gittes1 2016-01-25 gittes1 2016-01-24 gittes1 2016-01-23
is there way can extract rows gittes1 loaddate = 2016-01-25 using qualify statement. number of rows in partition can vary 0 n .. , there multiple such users.
if want records earliest loaddate
per username
, try
select username, loaddate table qualify rank() on (partition username order loaddate asc) = 1;
if want records latest loaddate
instead, replace asc
desc
in above.
Comments
Post a Comment