PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE st1 ( Id SERIAL PRIMARY KEY, npp CHARACTER VARYING(3), id_cell INTEGER, c_date CHARACTER VARYING(10), c_time CHARACTER VARYING(5), depos INTEGER ); INSERT INTO st1 (npp, id_cell, c_date, c_time, depos) VALUES ('RUP', 0, '2024-05-01', '22:00', 00), ('RUP', 0, '2024-05-01', '23:00', 20), ('RUP', 0, '2024-05-02', '00:00', 50), ('RUP', 0, '2024-05-02', '01:00', 90), ('RUP', 0, '2024-05-02', '02:00', 40), ('RUP', 0, '2024-05-02', '03:00', 10), ('RUP', 1, '2024-05-01', '22:00', 80), ('RUP', 1, '2024-05-01', '23:00', 60), ('RUP', 1, '2024-05-02', '00:00', 40), ('RUP', 1, '2024-05-02', '01:00', 30), ('RUP', 1, '2024-05-02', '02:00', 20), ('RUP', 1, '2024-05-02', '03:00', 10), ('RUP', 2, '2024-05-01', '22:00', 00), ('RUP', 2, '2024-05-01', '23:00', 00), ('RUP', 2, '2024-05-02', '00:00', 00), ('RUP', 2, '2024-05-02', '01:00', 00), ('RUP', 2, '2024-05-02', '02:00', 70), ('RUP', 2, '2024-05-02', '03:00', 90); SELECT DISTINCT id_cell, COUNT(depos) filter (where depos =0) AS PROB FROM st1 GROUP BY id_cell ORDER BY id_cell;
Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $now = Carbon::now()->format('d/m/Y'); printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion()); $query = "SELECT VERSION() as version;"; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); printf('DB version (PDO): %s ' . PHP_EOL, $row['version']); // Run query using mysqli $result = $mysqli->query($query); $version = $result->fetch_object(); printf('DB version (mysqli): %s ' . PHP_EOL, $version->version); // Select using Laravel $version = $db::select($query); printf('DB version (Laravel Query Builder): %s ' . PHP_EOL, $version[0]->version);
Show:  
Copy Clear