How can I count the times something has occured from odd and even number in SQL?
Posted on 2009-07-07
I have a very strange problem that I am trying to solve and am stuck.
I currently need to work out how many times an event would have occured depending on the total times it would have been possible. SOund confusing so I will explain.
There is a set interval for an event to happen, so for example every 10 days the colour of an item needs to alternate, so Red,Green,Red,Green,etc.
Now the total time to check this over is say 50 days, so the cycle has happened 5 times.
This means that Red has been shown 3 times and Green has been shown 2 times.
How can I work this out programtically within SQL? So for example the system querys the data and works out that the time of 74 days it would then work out how many times Green has been shown and how many times Red has been shown?