I am quite new with SQL and loops especially and need some help with the following problem.
I have a table like this:
SpotID EventID MaxTemp
123 1 45
236 1 109
69 1 18
123 2 216
236 2 29
69 2 84
123 3 91
236 3 457
69 3 280
I would like to generate a new table with the following output:
SpotID Over30 Over70 Over100
123 3 2 1
236 2 2 2
69 2 2 1
So what i am after is the count of how many times did the temperature exceed the limits of 30, 70 and 100 per SpotID for different EventIDs.
Is there a way to do this with a loop? My data set is obviously bigger and I am curious if how could i use something efficient.
Thank you very much.
Mike