sql - How to select distinct by 2 fields -
i need able select records have isactive = 1 in addition of this:
select distinct 0 communityid, case libname when 'rkhl' 'rock hill' when 'ftml' 'fort mill' when 'lanc' 'lancaster' when 'brev' 'brevard' when 'pbtc' 'midlands-clec' when 'pbti' 'midlands-ilec' end communitydesc, libname, libname + '|' filterbyid, isactive reference.dbo.community libname <> 'carotel' union select communityid, rtrim(commname) communitydesc, libname, libname + '|' + rtrim(commname) filterbyid, isactive reference.dbo.community libname <> 'carotel' order 1,3;
add isactive=1 clause on both sides of union.
Comments
Post a Comment