sql - Get distinct value of column with date check -
i've table errorlog following fields
id - primary key message- varchar(200) customerid - int createddate - datetime everytime logged in user gets error, logged in errorlog table.
now want fetch distinct message along all other fields createddate equal getdate()-1.
for example: if have these values in table 
then should output as

after query.
i'm not able distinct message value createddate. ideas how achieve this?
something should work:
with cte as( select *, row_number() over(partition message order createddate desc, customerid) rn table createddate < cast(getdate() date) , createdate >= dateadd(dd, -1, cast(getdate() date)) ) select * cte rn = 1
Comments
Post a Comment