INSERT INTO MyTABLE (Name, CapitalCity, LargestCity, Admission, Population)
select Name, CapitalCity, LargestCity, Admission, Population from OpenJson('
[
{
"name": "Alabama",
"capitalCity": "Montgomery",
"largestCity": "Birmingham",
"admission": "Dec 14, 1819",
"population": "4,903,185"
}, ...
')
with (
Name nvarchar(20) '$.name',
CapitalCity nvarchar(30) '$.capitalCity',
LargestCity nvarchar(20) '$.largestCity',
Admission nvarchar(20) '$.admission',
Population nvarchar(20) '$.population'
)
$sql = mysqli_query($link, "SELECT COUNT(*) cnt FROM reg WHERE name='$name' and password = '$password'");
while ($result = mysqli_fetch_array($sql)) {
if($result['cnt'] != 0){
echo 'логин и пароль верные';
}else{
echo 'неверный логин и пароль';
}
}
select @sum := 0;
select count(*)
from (select @sum := @sum + size sum_size
from `table`
) a
where sum_size < 1000000;
WHERE (`actions`.`update_time` <= '2019-09-18 10:54:38')
SELECT t.NAME AS TableName,
s.Name AS SchemaName,
p.rows,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,
CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
FROM sys.tables t
INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID
AND i.index_id = p.index_id
INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id
LEFT JOIN sys.schemas s ON t.schema_id = s.schema_id
WHERE t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY t.Name,
s.Name,
p.Rows
ORDER BY TotalSpaceMB DESC,
t.Name
сложение 1 и 4 записи, 3 запись. вот так получается.
грубо говоря, мы игнорируем все записили при повторе id_j. из-за этого везде, где в записях есть 2 в id_j игнорируются. и остаются три записи, которые суммируем
SELECT A.ID_H,
SUM(A.COST) COST
FROM (SELECT ID_H,
ID_J,
COST,
RANK() OVER(PARTITION BY ID_J ORDER BY ID_H ASC) RNK
FROM MYTABLE
) A WHERE A.RNK = 1
GROUP BY A.ID_H
@echo off
rem Имя компьютера из переменной окружения COMPUTERNAME
set fullName=%COMPUTERNAME%
rem echo %fullName%
rem Первые три симовла имени
set subName=%fullName:~0,3%
rem echo %subName%
rem Если имя начинается на 001 вывести true иначе false
IF %subName%==001 (echo true) ELSE (echo false)
rem Если имя начинается на 002 вывести true иначе false
IF %subName%==002 (echo true) ELSE (echo false)
SELECT r.id,
c.relation_cpu_id cpu_hash,
LISTAGG(m.relation_monitor_id, ', ') WITHIN GROUP (ORDER BY m.id) AS monitor_hash
FROM report r
LEFT JOIN v_cpu_relation c ON r.id = c.relation_report_id
LEFT JOIN v_monitor_relation m ON r.id = m.relation_report_id
GROUP BY r.id,
c.relation_cpu_id