I have the following table:
create table test (
id int identity,
base sysname not null,
login varchar(255), -- actually it is "uid int FK refs staff(uid)"
date datetime not null,
value int not null
)
How select rows from this table having single row per login and
1. where base=<constant>
2. date=MAX(date)
Notice that MAX(date) is DIFFERENT for different users!
Solution I don't like is to take logins from another table into cursor
(@login) and select row by row using the query
select * from test where base=<constant> and login=@login and date=(query MAX(date) from test where base=<constant> and login=@login)
Is it possible to avoid cursor?
create table test (
id int identity,
base sysname not null,
login varchar(255), -- actually it is "uid int FK refs staff(uid)"
date datetime not null,
value int not null
)
How select rows from this table having single row per login and
1. where base=<constant>
2. date=MAX(date)
Notice that MAX(date) is DIFFERENT for different users!
Solution I don't like is to take logins from another table into cursor
(@login) and select row by row using the query
select * from test where base=<constant> and login=@login and date=(query MAX(date) from test where base=<constant> and login=@login)
Is it possible to avoid cursor?