Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
I have table CUSTOMERDOCUMENT with fields customerdocumentid, customernumber, expirydate, documenttype
I want to find max(customerdocumentid) for each customernumber and i'm using query:
SELECT customernumber, documenttype, expirydate FROM CUSTOMERDOCUMENT WHERE customerdocumentid IN (SELECT max(customerdocumentid) from customerdocument as cd where cd.customernumber=customernumber);
In table is only 100000 rows but the query works an hour or even longer.
Is it possible to make this query works shorter? Can anybody suggest anything?
Thanks!
Thats a database problem. You need an db-index on customerdocumentid and customernumber, then it should work.
Greetings Alex:)
Thats a database problem. You need an db-index on customerdocumentid and customernumber, then it should work.
Greetings Alex:)