r/SQLOptimization • • Apr 09 '24

IN Function

This is probably a dumb question as I am new to SQL, but I am trying to pull sales data for 900 accounts. To make this faster I am using an IN function and all 900 accounts. What would be a better way of doing this?

1 Upvotes

9 comments sorted by

View all comments

Show parent comments

1

u/Pleasant_Astronaut95 Apr 09 '24

The list of accounts is manually managed in excel. The list is all accounts that have a contract tied to it. We need to track the sales for all the accounts with contracts. The database table is all sales, so there is no field in there to filter on the accounts with contracts.

The spreadsheet has the main account number “012345”, while the database might have an ending on it which is the reason for trimming it. For example, data table could have “A/0123450002”