I want to write a rule in which I want to compare the value of the current event with the previous event value. how can I write this rule in drools?
You can use temporal operators that are available in Drools. E.g. "after" or "before". See examples in the documentation [1].
[1] https://docs.jboss.org/drools/release/7.16.0.Final/drools-docs/html_single/index.html#_after