mardi 24 avril 2018

Date Calcs , possible use of partition/row functions

I have a table containing invoice level data and I have a business request to create a table containing New Business dollars to be awarded to sales reps.

Here is the logic: 1 - If no sales have been made to this customer in the past 6 months or if the customer is a new customer (not existing in the table), count sale as 'new business'. 2 - New Business Credit will last for the next 3 months after first qualifying 'New Business' sale.

Table Structure (for sake of simplicity) Customer # - Invoice # - Invoice Dt - Total $$

Sounds simple enough but i'm having a bit of trouble framing it in sql. Any thoughts?

Aucun commentaire:

Enregistrer un commentaire