QuickBase Example

Reference: http://community.intuit.com/posts/unique-records-equivalent-to-distinct-count-sql-formula https://www.quickbase.com/db/bf2i2xcu5

HTML

<script id="template" type="text/x-jquery-tmpl">
    < tr > < td > $ {
        operator
    } < /td>
    <td>${facility}</td > < td > $ {
        value
    } < /td>
   </tr >
</script>
<table border="1">
    <thead>
        <tr>
            <th>Operator</th>
            <th>Facility</th>
            <th># Surveys</th>
        </tr>
    </thead>
    <tbody id="tbody"></tbody>
</table>

CSS

th, td {
    padding: 5px;
}

JavaScript

$.ajaxSetup({
    async: false
});
$.getScript("https://www.quickbase.com/db/befe2yy7d?a=dbpage&pagename=underscore-min.js");
$.getScript("https://www.quickbase.com/db/befe2yy7d?a=dbpage&pagename=jquery.tmpl.min.js");

var counts = {};
var key, keysplit;
var operator, facility;

var url = "";
url += "https://www.quickbase.com/db/bf2i2xcx3";
url += "?act=API_GenResultsTable";
url += "&qid=6";
url += "&jsa=1";

$.getScript(url, function () {
    _.each(qdb_data, function (record, index) {
        key = record[0] + ":" + record[1];
        counts[key] = (counts[key] || 0) + 1;
    });
    var data = [];
    _.each(counts, function (value, key) {
        keysplit = key.split(":");
        operator = keysplit[0];
        facility = keysplit[1];
        data.push({
            operator: operator,
            facility: facility,
            value: value
        });
    });
    $("#template").tmpl(data).appendTo("#tbody");
});