Geographic Information Systems Asked on August 5, 2021
I am very new to QGIS and SQL.
I have two layers, each is populated with points and temporal data. One layer has information on battles occuring in Iraq and Syria, and the other has information on terror attacks. I would like to extract information about the distance of each terror attack to the nearest battle, within 30 days.
I have two SpatiaLite layers and have tried the following query to create a new virtual layer:
SELECT battles.data_id as id_battles, terror.fid as id_terror,
ROUND(MIN(ST_Distance(acled.geometry, fullset.geometry)),2) AS distance
FROM ACLED AS battles, FullSet_Prio2 AS terror
WHERE battles.'date' BETWEEN terror.'date' AND (terror.'date' - 1 month)
GROUP BY terror.fid
ORDER BY distance DESC
This returns a syntax error at the -1 month
line. +
The query works if I use ==
instead of WHERE...BETWEEN...AND
but that’s not the information I need.
Could anyone help me figure out the correct syntax for substracting from dates or do I need to do something else instead?
I tried creating a virtual layer using this:
WHERE day(age(fullset.'date', acled.'date')) < 30
This doesn’t result in an error, but results in empty rows.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP