Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
Query to get statistic from SQL Server

I need to create a table in my web pages that show the statistics of sales, for clarification, I have a table in SQL server that shows the daily sales I want to show in my web page a column present the days without duplication and next to every date the sum of sales for that days and then the sales for every branch in that day, I just can not match every single date with its statistic

        <?php
        $r            = "SELECT distinct invoice_date from total_sales";
        $result       = sqlsrv_query($conn,$r);
        $rresult      = sqlsrv_query($conn,'SELECT distinct invoice_date from total_sales');
        if( $result === false) {
            die( print_r( sqlsrv_errors(), true) );
        }
          while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)){
            $dataaaa = $row;

            foreach ($dataaaa as $value) {
              print_r($value . "<br/>");
            }

            // foreach ($dataaaa as $row => $value) {
            //   print_r($value . "<br />");
            // }
        }
        $mm = $value;
        $num        = 1;
        $r         = "SELECT * from total_sales where invoice_date = $mm";
        $params2    = array();
        $options2   =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
        $stmt2      = sqlsrv_query( $conn, $r , $params2, $options2 );

        $lateCount2 = sqlsrv_num_rows( $stmt2 );


        if ($lateCount2 === false)
           echo "Error in retrieveing row count.";
        else
           echo $lateCount2;
        ?>

        <?php
        while($user = sqlsrv_fetch_array($rresult)){
          echo '
          <tr>
          <td scope="row">'.$num++.'</td>
          <td>'.$user['invoice_date'].'</td>
          <td>'.$mm.'</td>
          <td><a href="?user_edit='.$user['invoice_date'].'" class="editBtn" name="log" onclick="goBack()">'.$lateCount2.'</a></td>
          </tr>
          ';
        }
        ?>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda