Let’s say you needed to find the maximum and minimum values for a field in a SQL database. If you’re like most people, you might write a query like SELECT MAX(someval), MIN(someval) FROM table.

That’s the least you could do. That’s the bare minimum. And do you want to be the kind of person who does the bare minimum? Kevin L’s co-worker doesn’t. He’s a Brian.

  $querymin = " select hmid ";
    $querymin .= " from  tagdetail ";
    $querymin .= " Where tagdetail.tag_ordr_ref=$grphdr_tag_ordr_ref";
    $querymin .= "   and tagdetail.refgrp=$grphdr_refgrp ";
    $querymin .= " order by hmid ";

    $resultmin = displayTable($conn_id1, $querymin, "N", "");
   $counter = 1;

    foreach ($resultmin as $a) {
        $count_rcds = $count_rcds + 1;
        if ($counter == 1) {
            $min_hmid = (trim($a [hmid]));
        }

        $max_hmid = (trim($a [hmid]));
        $counter = $counter + 1;
    }

That’s way better than using aggregate functions.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!