Viewing 15 posts - 1,276 through 1,290 (of 3,500 total)
What do you mean by "nearest to today"? Can be either before or after? Then you'd have to do MIN of ABS(DATEDIFF....) or return the top 1 value...
July 18, 2018 at 8:25 pm
You shouldn't be grouping by EventDate - you're trying to return a MIN([EventDate]), so grouping by it (return each unique value) doesn't make sense.
July 18, 2018 at 4:42 pm
If you have control over the design of the table, you could create a new column and extract just that part to the new column. Then you could index it...
July 11, 2018 at 3:03 pm
Could you post some sample data - insert statements so we have something to work with? Basically, you can use LAG with a window to get the "previous" record, and...
July 10, 2018 at 3:11 am
Maybe this?SELECT member,
amt_paid,
amt_adjusted,
dt,
dupeNum
FROM
( SELECT member,
amt_paid,
amt_adjusted,
dt,
ROW_NUMBER() OVER (PARTITION BY member, dt, amt_adjusted ORDER BY member, dt) AS dupeNum
June 11, 2018 at 10:14 am
June 11, 2018 at 10:12 am
Kinda would help if I wrote an actual delete query... =)
Test the CTE out by doing SELECT from it first instead of DELETE;WITH
cteMembers(member, amt_paid,...
June 10, 2018 at 7:02 pm
June 10, 2018 at 5:09 pm
Like this? It's not super clear what you want. In this case, a sample expected result would be a big help. Something like this?Create table #t( member...
June 10, 2018 at 5:08 pm
Hi
I have below Data .