Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Selecting records using If or CASE statement

Author  Topic 

axapta
Starting Member

11 Posts

Posted - 2006-07-01 : 08:02:03
Hi All,
I've tried to get this to work but I'm having problems in constructing the statement:
I've got a table called SiteData. The structure is as follows:

SiteID SuspensionStart Notice Period MergeID MergeStatus
225 17/07/2006 7 224 1
224 25/07/2006 7 225 2


I need to select only one of the above records using the following criteria:
if CurrentDate <= due date for date 1, then select record on due date for date 1 but do not select record on due date for date 2.

if currentdate > due date for date 1 then select record on due date for date 2

Due Date = SuspensionStart - Notice

TIA

axapta
Starting Member

11 Posts

Posted - 2006-07-01 : 08:05:38
A bit more info:
1 in the mergestatus field means this is the earlier date of the two records, whereas 2 in the mergestatus field indicates the later date of the two records. Maybe this flag can be used in the CASE statement?
Thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-07-01 : 12:33:17
It seems that one field of test data is missing.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

axapta
Starting Member

11 Posts

Posted - 2006-07-01 : 13:07:15
Apologies, I couldn't get the headings to line up properly.

The headings are:
SiteID
SuspensionStart
Notice Period
MergeID
Mergestatus

The data is separated by a space.
Thanks.
quote:
Originally posted by Peso

It seems that one field of test data is missing.


Peter Larsson
Helsingborg, Sweden

Go to Top of Page
   

- Advertisement -