Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda