Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
FleetingImage
Contributor II
Contributor II

Where Exists() not filtering records

I have a  qvd table  that looks like this:

IdkeyAmt
6709661624.19
6709662620
6709663645.13

*It has about 6M records

I want to keep the record with the max(key), so I'm doing as follows:

tbl1:

Load

Id

,key

,Amt

from tbl1.qvd

 

noconcatenate

max_key:

Load

Id

,max(key) as maxKey

Resident tbl1;

 

noconcatenate

tblNoDup:

Load

*

Resident tbl1

where Exists(maxKey, key)

;

drop table tbl1,  max_key;

 

I expect that tblNoDup shows:

IdkeyAmt
6709663645.13

 

But Instead, is returning all three records.  What am I missing?

 

 

 

 

 

 

Labels (1)
1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

add a group by to your max load

 

max_key:

Load

Id

,max(key) as maxKey

Resident tbl1 group by Id;

View solution in original post

1 Reply
dplr-rn
Partner - Master III
Partner - Master III

add a group by to your max load

 

max_key:

Load

Id

,max(key) as maxKey

Resident tbl1 group by Id;