<%= render 'form' %>

<% if @result.empty? %>
No results found.
<% else %>
<hr />

<table>
  <thead>
    <tr>
      <% @result.fields.each do |field| %>
        <th><%= field %></th>
      <% end %>
    </tr>
  </thead>

  <tbody>
    <% @result.each do |row| %>
      <tr>
	<% row.each do |cell| %>
          <td><%= cell %></td>
	<% end %>
      </tr>
    <% end %>
  </tbody>
</table>
<% end %>

<%= render 'form' %>

<hr />

<table>
  <thead>
    <tr>
      <% @result.fields.each do |field| %>
        <th><%= field %></th>
      <% end %>
    </tr>
  </thead>

  <tbody>
    <% @result.each do |row| %>
      <tr>
	<% row.each do |cell| %>
          <td><%= cell %></td>
	<% end %>
      </tr>
    <% end %>
  </tbody>
</table>

Check for empty report result does not work.
Check for empty report result does not work.
