Help Needed - print mutliple lines

I have the following input

-- appl = host = user = / pid = 76 elapsed = 0.000 seconds server_elapsed = 2.999
select emp_no, dept_no
from emp
where empname like 'Rob%'
and empno=10
;

-- appl = host = user = / pid = 76 elapsed = 0.000 seconds server_elapsed = 0.999
select emp_no, dept_no
from dept
where deptname like 'IT%'
;

The above input need to print the following output.

2.999 |select emp_no, dept_no from emp where empname like 'Rob%' and empno=10;
0.999 |select emp_no, dept_no from dept where deptname like 'IT%' ;

I have files with thousands of statements, I need to format them as above.

I appreciate your kind help and reply.

Quick and dirty code to re-format your queries - assumes that each one starts with a comment preceded by "--"

while read a
do
if [[ $a = --* ]]; then
  print
  lf=$(echo $a|wc -w);
  print -n "$(echo $a|cut -d' ' -f $lf) |"
else
  print -n " "$a
fi
done < YourOriginalFile > YourReformattedFile

cheers

Thanks for your quick and dirty code to solve my problem. As I am a new to this kind of work, I could not able to understand the solution but it is great. I have one more request to the output. If I need only specific rows like I do not want 0.000 rows to the out put. then How can I proceed. I know one way, to do this by grep -v. But anyother way.

Thanks for your reply and help.

Try...

awk '/^--/ && $NF>0 {printf $NF "|"; do {getline; printf $0 (/;/?ORS:OFS)} while (!/;/)}' file1 > file2

how this the current post different from this one

That awk line is terrific!
But using shell script with same assumptions as before, to suppress zeros:

while read a
do
if [[ $a = --* ]]; then
  lf=$(echo $a|wc -w)
  secs=$(echo $a|cut -d' ' -f $lf)
  msecs=$(( $secs * 1000))
  if [ $msecs -gt 0 ]; then
    print
    print -n "$secs |"
  fi
else
  if [  $msecs -gt 0 ]; then
    print -n " "$a
  fi
fi
done < YourOriginalFile > YourReformattedFile

cheers