clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1579708 fiddles created (21392 in the last week).

CREATE TABLE Table1(account int, ip_address varchar(15), created_date date); INSERT INTO Table1 VALUES (1, '10.0.0.1', '20170101'), (1, '10.0.0.1', '20170201'), (1, '10.0.0.1', '20170301'), (2, '10.0.0.2', '20170201'), (3, '10.0.0.3', '20170201'); CREATE TABLE Table2(ip_address varchar(15), created_date date); INSERT INTO Table2 VALUES ('10.0.0.1', '20170201'), ('10.0.0.2', '20170201'), ('10.0.0.3', '20170201');
8 rows affected
 hidden batch(es)


SELECT (SELECT TOP (1) account FROM Table1 t1 WHERE t1.ip_address = t2.ip_address AND t1.created_date >= t2.created_date ORDER BY t1.ip_address, t1.created_date desc) account, t2.ip_address, t2.created_date FROM Table2 t2
account ip_address created_date
1 10.0.0.1 01/02/2017 00:00:00
2 10.0.0.2 01/02/2017 00:00:00
3 10.0.0.3 01/02/2017 00:00:00
 hidden batch(es)