sql >> Base de Datos >  >> RDS >> Mysql

agrupar valores tándem exactos de 2 columnas?

Podrías hacer esto usando PHP:

$query = mysqli_query("SELECT time, lat, `long` FROM Points ORDER BY time");

// output header row
echo str_pad('time', 8) .'|';
echo str_pad('lat', 7) .'|';
echo "long\n";

$prevLat = $prevLong = '';
while ($row = mysqli_fetch_assoc($query)) {
    if ($row['lat'] === $prevLat && $row['long'] === $prevLong) {
        // if this row's lat and long values are the same as the
        // previous row's values, skip this row.
        continue;
    }

    $prevLat  = $row['lat'];
    $prevLong = $row['long'];

    echo str_pad($row['time'], 8) .'|';
    echo str_pad($row['lat'], 7) .'|';
    echo "{$row['long']}\n";
}

Aquí hay una muestra:http://codepad.org/c0SjA058