The problem is, when using the command line, the //echo -a $query(0) always goes to your current connection, not the connection you think it would go to due to the usage of /scid

Try doing it as a script
Code:
alias query_test_1 {
  var %a = 1, %b = $scon(0)
  while %a <= %b {
    var %cid = $scon(%a).cid
    scid %cid
    echo -a Connection ID $cid Queries $query(0)
    inc %a
  }
}

A shorter code that shows the same information
Code:
alias query_test_2 {
  .scon -at1 echo -a $!cid $!query(0)
}

FYI: testing these over 3 networks, the first run ran in 31 milliseconds, the 2nd in 16 milliseconds.