group by - SQL Select from a single compound table -
i'm new sql, apologies if got nomenclature wrong (or if solution blindingly obvious).
my code like:
select client_id, max(year_end_date), acct_nbr ( -- ** subquery ** ) aa group client_id, acct_nbr;
the columns in subquery same main query. duplicates in answer - meaning same given client_id
db2 returns multiple rows different dates - example
client_id | year_end_date | acct_nbr ------------------------------------- 20001 2003-12-31 01 20001 2005-12-31 01
any idea why?
try this:
select '>>' || client_id || '<<', max(year_end_date), '>>' || acct_nbr || '<<' ( -- ** subquery ** ) aa group client_id, acct_nbr;
you can try calling trim()
on client_id , acc_nbr fields in sub-query. think have hidden spaces there.
Comments
Post a Comment