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
 General SQL Server Forums
 New to SQL Server Programming
 finding a number out of sequence

Author  Topic 

aciccia
Starting Member

8 Posts

Posted - 2011-07-25 : 23:18:33
What I am trying to do is look for a gift card that is used out of sequence by 1000. The transaction code '71' refers to gift cards processed. The sd_key refers to the customer number.

The problem is in the are of where the +/- 1000 is, since I can delete part of it and get some results.


Thank you.


select *



from

aar_ANALYTICS.dbo.detail d

Inner

join aar_analytics.dbo.detail di

on

d.SD_KEY=di.SD_KEY

where

d.SD_TRAN_CDE_CAT in ('71')

and

di.SD_Tran_cde_cat in ('71')

and di.ND_Crd_Num > d.ND_Crd_Num + 1000

and di.ND_Crd_Num < d.ND_Crd_Num - 1000


and di.DD_DATE BETWEEN DATEADD(day, -10, d.DD_DATE) AND DATEADD(second, -5, d.DD_DATE )


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-25 : 23:26:21
This seem odd to me? How can a cardnum be BOTH greater than AND less than at the same time?
Change to this

and ( di.ND_Crd_Num > d.ND_Crd_Num + 1000 or di.ND_Crd_Num < d.ND_Crd_Num - 1000 )



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

aciccia
Starting Member

8 Posts

Posted - 2011-07-25 : 23:34:27
I made that adjustment you suggested and it works now, Thank you
Go to Top of Page
   

- Advertisement -