thanks for your reply, i didn't think this way and you open new things in my mind :)But, this does not solve the problem because if you pay a ticket that is periodic, this ticket will show twice if you execute a new query. Example: If you have a ticket that starts on January/10 and ends on December/10 value=250,00, when i execute this query:SELECT date, Paid, value, PeriodicFROM YourTableWHERE date BETWEEN '20100201' And '20100530'And Periodic = 0UNION ALLSELECT date, Paid, value, PeriodicFROM YourTableWHERE Periodic = 1
I will get this:Date Paid Value Periodic2010-05-01 NULL 74,00 02010-05-10 NULL 1078,00 02010-01-01 2010-01-01 250,00 1
You can see 2 records that needs to pay month 5, and you see 1 record with 'wrong' date and seens to be already paid.What i really want is something like this:Date Paid Value Periodic2010-05-01 NULL 74,00 02010-05-10 NULL 1078,00 02010-02-01 NULL 250,00 12010-03-01 NULL 250,00 12010-04-01 NULL 250,00 12010-05-01 NULL 250,00 1
I think this is complicated to deal with a query, maybe a stored procedure with some code and loops.Is it better to solve this inside the code at user interface (C#.NET) or inside stored procedure?thanks