Reply to Get previous record

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация