The process C:\Windows\system32\wlms\wlms.exe (DESKTOP-OB87TTK) has initiated the shutdown of computer DESKTOP-OB87TTK on behalf of user NT AUTHORITY\SYSTEM for the following reason: Other (Planned)
Reason Code: 0x80000000
Shut-down Type: shutdown
Comment: The license period for this installation of Windows has expired. The operating system is shutting down.
надо что бы при запросе вывел где status= true, и count_id = количество id за 30 дней.
|id|id_2|name|status|date| count_id |
|id|id_2|name|status|date| count_id |вывести не получится! т.к. группировать по полям |id|id_2|name| не имеет смысла, они могут быть уникальны и никакого COUNT за интервал не получится, например как считать количество в интервале для id=1,2,3 ... ??? это группироваться никак не будет вообще, будет выводиться построчно для каждого id и количество будет Всегда равно =1 и так для всех id. определитесь что вам надо?! конкретно
SELECT count(id) count_id
FROM tbl
WHERE status = 'true'
AND date >= now() - interval 30 day
;
-- дата начала
DECLARE @t_start AS DATETIME = DATEADD(minute, -7410, GETDATE());
-- дата конца
DECLARE @t_finish AS DATETIME = GETDATE();
-- разница между датами начала и конца в переменной типа DATETIME
DECLARE @t_diff AS DATETIME = @t_finish - @t_start;
-- разница между датами начала и конца
SELECT @t_diff;
SELECT DATEDIFF(second, DATEFROMPARTS(1900,1,1), @t_diff) / 3600.0 AS diff_h
datevalue "TO_DATE( :datevalue , 'YYYY-MM-DD')"
{"2019-12-22":[{"dt":1577048400,"main":{"temp":-21.94,"feels_like":-26.97,"temp_min":-22.46,"temp_max":-21.94,"pressure":1018,"sea_level":1018,"grnd_level":1013,"humidity":99,"temp_kf":0.52},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"clouds":{"all":34},"wind":{"speed":1.97,"deg":139},"sys":{"pod":"n"},"dt_txt":"2019-12-22 21:00:00"}],
...}
let wd = {};
data.list.map(e => {
let dt = e.dt_txt.split(" ")[0];
if(typeof(wd[dt])!="undefined") {
wd[dt].push(e);
} else {
wd[dt] = [];
}
});
console.log(JSON.stringify(wd));
let iconUrl="";
let wdate = ""; // переменная состояния
function forecastTemplate (localData) {
let s = "";
if (localData.dt_txt.split(" ")[0] != wdate) {
wdate = localData.dt_txt.split(" ")[0];
s += `
<tr><td colspan=2>${wdate}</td>
`;
}
s += `
<tr>
<td>
<div class="flex">
<div>
<span>${localData.dt_txt.split(" ")[1]}<span>
</div>
<div>
<img src="${iconUrl}${localData.weather[0].icon}@2x.png">
</div>
</div>
</td>
<td>
<div class="flex">
<div>
<span class="temp">${localData.main.temp}℃</span>
</div>
<div>
<span class="description">${localData.weather[0].description}</span>
</div>
</div>
<div class="flex">
<div>
<span>wind: ${localData.wind.speed} m/s,</span>
</div>
<div>
<span>clouds: ${localData.clouds.all}%,</span>
</div>
<div>
<span>pressure: ${localData.main.pressure} hPa</span>
</div>
</div>
</td>
</tr>`
return s
}
let html = "";
document.body.innerHTML = `<table>${data.list.map(forecastTemplate).join("")}</table>`;
SELECT
c.title,
ou.name,
m.text,
FROM_UNIXTIME(m.date) AS dt
FROM chat_users cu
INNER JOIN chat_users cuu ON cuu.chat_id = cu.chat_id AND cuu.user_id != cu.user_id
INNER JOIN users ou ON ou.id = cuu.user_id
INNER JOIN chat c ON c.id = cu.chat_id
INNER JOIN messages m ON m.user_id = cuu.user_id AND m.chat_id = cu.chat_id
WHERE cu.user_id = :ID_USER -- ID пользователя по которому выбирать чаты.
ORDER BY c.title ASC, m.date DESC
SELECT
position, count(1) AS n
FROM (
SELECT
position, row_number() OVER (PARTITION BY position) rn
FROM tbl
) t
GROUP BY position, (rn+1) div 2
;
SELECT *
FROM order_kassa
WHERE str_to_date(doc_time, '%d.%m.%Y') BETWEEN '2019-11-01' AND '2019-11-20';
SELECT
e.*, c.`click`, c.`unique_click`
FROM (
SELECT
DATE(FROM_UNIXTIME(`inserted_at`)) as `day`,
SUM(IF(`type` = 2, `total_cost`, 0)) as `f_sum`,
SUM(IF(`type` = 3, `total_cost`, 0)) as `d_sum`,
SUM(IF(`type` = 4, `total_cost`, 0)) as `w_sum`,
FROM `event`
GROUP BY `day`
) e
INNER JOIN (
SELECT
DATE(FROM_UNIXTIME(`inserted_at`)) as `day`
SUM(IF(`type` = 1, 1, 0)) as `click`,
SUM(IF(`type` = 2, 1, 0)) as `unique_click`,
FROM `click`
GROUP BY `day`
) c ON e.`day` = c.`day`
ORDER BY e.`day` DESC
LIMIT 10
;
ALTER TABLE persons
ADD CONSTRAINT persons_check_rols CHECK (rols in('registrator', 'coordinator', 'user'));
SELECT
w.Id
,w.IMO
,v.Name
,w.loginManager
,um.Name AS managerName
,w.loginStorekeeper
,umk.Name AS storekeeperName
,w.Date
FROM Waybill w
INNER JOIN Vessel v ON w.IMO = v.IMO
INNER JOIN User um ON w.loginManager = um.Login
INNER JOIN User umk ON w.loginStorekeeper = umk.Login
ORDER BY w.Id
-- здесь я вынес параметры (домены, языки) в отдельное представление param,
-- которое определяется перед SELECT
-- это сделано, для того чтобы по всему запросу не искать и вписывать их
-- меняется все в одном месте:
WITH param AS (
SELECT
2 AS primary_domain_id, -- id первичного домена
1 AS secondary_domain_id, -- id вторичного домена
2 AS primary_language_id, -- id первичного языка
1 AS secondary_language_id -- id вторичного языка
FROM dual
)
SELECT *
FROM (
SELECT m.*,
row_number() over (
partition by m.movie_id
order by
case
when m.domain_id = p.primary_domain_id then 100
when m.domain_id = p.secondary_domain_id then 50
else 1
end DESC,
case
when m.language_id = p.primary_language_id then 100
when m.language_id = p.secondary_language_id then 50
else 1
end DESC
) rn
FROM `movie_desc` m, param p
WHERE (m.domain_id = p.primary_domain_id
OR m.domain_id = p.secondary_domain_id
OR m.domain_id IS NULL)
AND (m.language_id = p.primary_language_id
OR m.language_id = p.secondary_language_id
OR m.language_id IS NULL)
) t
WHERE t.rn = 1
;
SELECT
name,
sku,
CONCAT('https://домен/', IF(ua2.keyword IS NULL,'',CONCAT(ua2.keyword, '/')), IF(ua3.keyword IS NULL,'',CONCAT(ua3.keyword, '/')), IF(ua4.keyword IS NULL,'',CONCAT(ua4.keyword, '/')), ua1.keyword) AS url
FROM (
SELECT
name,
p.sku,
CONCAT( 'product_id=', p.product_id ) AS product_query,
CONCAT( 'category_id=', pc.category_id ) AS category_query,
CONCAT( 'series_id=', ps.series_id ) AS series_query,
CONCAT( 'subcategory_id=', psc.subcategory_id ) AS subcategory_query
FROM `oc_product_description` pd
LEFT JOIN oc_product p ON (p.product_id=pd.product_id)
LEFT JOIN oc_product_to_category pc ON (pc.product_id=p.product_id)
LEFT JOIN oc_product_to_series ps ON (ps.product_id=p.product_id)
LEFT JOIN oc_product_to_subcategory psc ON (psc.product_id=p.product_id)
WHERE p.date_available <= NOW()
AND p.status = '1'
) pd
LEFT JOIN oc_url_alias ua1 ON ( pd.`product_query` = ua1.`query` )
LEFT JOIN oc_url_alias ua2 ON ( pd.`category_query` = ua2.`query` )
LEFT JOIN oc_url_alias ua3 ON ( pd.`series_query` = ua3.`query` )
LEFT JOIN oc_url_alias ua4 ON ( pd.`subcategory_query` = ua4.`query` )
;
(SELECT DISTINCT(Name) AS storekeeperName FROM User, Waybill WHERE (Waybill.loginStorekeeper = User.login))
SELECT
Waybill.Id, Waybill.IMO, Vessel.Name, Waybill.loginManager, User.Name, Waybill.loginStorekeeper,
(SELECT DISTINCT(Name) AS storekeeperName FROM User, Waybill WHERE (Waybill.loginStorekeeper = User.login)) AS storekeeperName,
Waybill.Date
FROM Waybill, Vessel, User
WHERE (Waybill.IMO = Vessel.IMO)
AND (Waybill.loginManager = User.Login)
AND (Waybill.loginManager = User.Login)
ORDER BY Waybill.Id
Можно ли дойдя с помощью цикла до свойства hosts понять, что оно является объектом?
console.log(typeof({}));
// object
for (var key in data) {
if(typeof(data[key]) == "object") {
console.log (key + " is object");
}
}
Просто мне необходимо в этом случае, добавлять в тело цикла(или условия) после самого объекта(в данном случае data), или .объект или [свойство].
Кстати, с помощью какого метода, я смогу это всё добавлять? Мне нужно добавить либо data.hosts либо data[свойство]
data["hosts"][2] = {name: 'web3'}
data["hosts"][data["hosts"].length] = {name: 'web3'}
// или
data["hosts"].push( {name: 'web3'} );
const data = {
user: 'ubuntu',
hosts: {
0: {
name: 'web1',
},
1: {
name: 'web2',
null: 3,
},
},
};
// классически на if
function getIn(obj, parr) {
if(typeof(obj[parr[0]]) == "undefined") {
return null;
} else {
if(typeof(obj[parr[0]]) == "object") {
if(parr.length > 1) {
return getIn(obj[parr[0]], parr.slice(1))
} else {
return obj[parr[0]]
}
} else {
return obj[parr[0]];
}
}
}
// защита от дурака (когда некорректные параметры) + switch case
function getIn(obj, parr) {
if (
typeof(obj) != "object" ||
typeof(parr) != "object" ||
parr.length == "undefined" ||
parr.length == 0
) return null;
switch (typeof(obj[parr[0]])) {
case "undefined":
return null;
case "object":
return (parr.length > 1)? getIn(obj[parr[0]], parr.slice(1)):obj[parr[0]]
default:
return obj[parr[0]];
}
}
// еще короче
function getIn(obj, parr){
return !(
typeof(obj) != "object" ||
typeof(parr) != "object" ||
parr.length == "undefined" ||
parr.length == 0
)?
typeof(obj[parr[0]]) == "object" ?
(parr.length > 1)?
getIn(obj[parr[0]], parr.slice(1)):obj[parr[0]] :
obj[parr[0]] ?
obj[parr[0]]: null:
null
}
// и стрелочной функцией
const getIn = (obj, parr) => !(
typeof(obj) != "object" ||
typeof(parr) != "object" ||
parr.length == "undefined" ||
parr.length == 0
)?
typeof(obj[parr[0]]) == "object" ?
(parr.length > 1)? getIn(obj[parr[0]], parr.slice(1)):obj[parr[0]] :
obj[parr[0]] ? obj[parr[0]]:null :
null;
function getIn(obj, parr) {
let o = obj;
for(let i=0; i< parr.length; i++) {
o = o[parr[i]];
if(typeof(o)=="undefined") return null;
}
return o;
}