thank you very much
yes your query is shorter and faster than main?
there is another problem?
I want result to be like this
time avg of(val)
11:15:00 34.5(it should include avg between 11 to 11:15)
11:30:00 43.6(it should include avg between 11:15 to 11:30)
that means time should start from 11.15 in first column it should contain avg of val between 11 to 11:15?......
1.how do preferred CTE in your query ? how to know which one works better than which ?is there any link that you can share?
I ALWAYS get confused while starting a new reporting project about using the CTE or temp table using case or if statement ? please reply
thank you once again