SQL upit: Polaznici koji su platili dva i više računa
============================================
<?php$link = mysqli_connect("localhost", "root", "", "mariva");
$sql = "SELECT prezime, ime, Count(racuni.id_racuna)
AS CountOfID_racuna
FROM polaznici_tecaja
INNER JOIN racuni
ON polaznici_tecaja.id_polaznika = racuni.id_polaznika
GROUP BY prezime, ime
HAVING Count(id_racuna)>=2
ORDER BY Count(id_racuna) DESC";
$result = mysqli_query($link, $sql);
While ($row = mysqli_fetch_assoc($result))
{
print $row["prezime"] . " " . $row["ime"] . " " .
$row["CountOfID_racuna"] . "<br>";
}
?>
SQL upit: Koliko je računa čiji je iznos veći od 400kn izdano svakom učeniku
===================================================================
<?php
$link = mysqli_connect("localhost", "root", "", "mariva");
$sql = "SELECT prezime, ime, Count(id_racuna)
AS CountOfID_racuna
FROM polaznici_tecaja
INNER JOIN racuni
ON polaznici_tecaja.id_polaznika = racuni.id_polaznika
WHERE iznos_racuna>400
GROUP BY prezime, ime
ORDER BY Count(id_racuna)";
$result = mysqli_query($link, $sql);
While ($row = mysqli_fetch_assoc($result))
{
print $row["prezime"] . " " . $row["ime"] . " " .
$row["CountOfID_racuna"] . "<br>";
}
?>
Primjedbe
Objavi komentar