|
Posted by teddysnips on 12/05/05 10:46
Please see DDL and INSERT statements below.
Let's say that some process throws out the second row, where the
Clocktime = '02/01/2005 12:34'
Without the use of a cursor, how can I retrieve the PREVIOUS value for
that employee? Pseudo SQL might be something like:
SELECT
*
FROM
tblTest
WHERE
fldCLocktime = THE-ONE-IMMEDIATELY-BEFORE '02/01/2005 12:34'
AND
fldEmployeeID = 1
TIA
Edward
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[tblTest]') and OBJECTPROPERTY(id, N'IsUserTable') =
1)
drop table [dbo].[tblTest]
GO
CREATE TABLE [dbo].[tblTest] (
[fldTestID] [int] IDENTITY (1, 1) NOT NULL ,
[fldEmployeeID] [int] NULL ,
[fldClocktime] [datetime] NULL ,
) ON [PRIMARY]
GO
INSERT INTO tblTest
(fldEmployeeID,
fldClocktime)
VALUES
(1,
'01/01/2005 12:34')
INSERT INTO tblTest
(fldEmployeeID,
fldClocktime)
VALUES
(1,
'02/01/2005 12:34')
INSERT INTO tblTest
(fldEmployeeID,
fldClocktime)
VALUES
(1,
'03/01/2005 12:34')
[Back to original message]
|