when i run the above query I am getting the below error at runtime :SQLException: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Difference of two datetime columns caused overflow at runtime.

The reason may be that Down_since,Up_Since, ETR etc date fields have some really early values (say 19000101 etc) so that datediff value in seconds is going beyond integer limit. Try using higher period like hh,minute etc and see it works first