New answers tagged sql
3
votes
Accepted
Adding parcel number to site when there are many sites in QGIS
I'm not sure I completely understand your question, but [add autoincremental field] in the qgis toolbox may be able to help you. It can take all fields with a specific value and assign numbers to each ...
- 98
5
votes
Adding parcel number to site when there are many sites in QGIS
You can use row_number and partition by site:
--Create a test table
drop table if exists public.test;
create table public.test (id serial, siteid varchar(10));
insert into public.test (siteid)
values ...
- 61.1k
0
votes
Performing ST_Distance query in file geodatabase using ArcGIS Pro
Although the existing answer and comments still stand, i.e., not possible with file geodatabases, it is worth pointing out this is possible with mobile geodatabases. As support for mobile ...
- 1,658
3
votes
Accepted
PostGIS subquery error when trying to randomly distribute points in polygons
Technically, @RainForest's solution directly adresses the error you are seeing; you are SETing a single column so the respective expression (here the sub-query) must return a single value (here the ...
- 27.1k
2
votes
PostGIS subquery error when trying to randomly distribute points in polygons
Just delete pt.*, from subquery
SELECT
ST_GeneratePoints(lsd.geom, 1, floor(random() * 5000 + 1)::int)
FROM
public.unjoined_pts2 AS pt,
public.grid_concave_hull AS lsd
WHERE
...
- 885
4
votes
QGIS, Rule-Based Symbology Not Working, But Feature Filter Does
Short answer:
Rule based styling expressions are not SQL, use the expression syntax instead
- 2,777
4
votes
QGIS - Countif function on columns
You can aggregate the values in an array, filter all elements greater than 0 and then get the length of the filtered array:
Use this expression in the field calculator on the layer itself:
...
- 12.2k
5
votes
I need to expect multi value with if statement
You need to replace ' and' with ''. E.g. Ahmed and Marten -> Ahmed Marten, and then check replaced_name is title(replaced_name).
Use this expression:
with_variable(
'text', -- variable name
...
- 70k
0
votes
I need to expect multi value with if statement
I don't know if I understand your question correctly.
But try something like:
if( strpos( 'the name you are searching for' , "name" ) > 0 , 'yes' , 'no' )
- 382
8
votes
Accepted
Using eval function in Virtual Layer in QGIS
This is an interesting question that has piqued my interest. As I'm working in QGIS Windows, I set SPATIALITE_SECURITY=relaxed in the global Windows environment.
After many trials and errors, I found ...
- 4,651
1
vote
Is it possible to make a condition for a field in QGIS using CSV
So I understand that Table 2 already contains the num and obey fields? If so, you can just perform a Table Join using the Join attributes by field value from the Processing algorithm Toolbox.
A ...
- 393
7
votes
Accepted
Creating virtual layer with extent of features from multiple layers in QGIS
Use this query, where in the last line, replace id with the attribute name that should have the same value and replace poly and lines with the names of your layers:
SELECT
bounds(st_union(g1....
- 55.3k
2
votes
GeoJSON from SQL View
You seem to have a logical misconception in your approach, leading to the syntax issue:
you are sending a FeatureCollection to the server to eventually get passed into the query - however, ...
- 27.1k
0
votes
GeoJSON from SQL View
NB: This answer was for an earlier edition of the question which was using GET rather than POST. Therefore this answer is no longer relevant, due to edits to the question.
OPTION 1
Use an HTTP POST ...
- 7,364
6
votes
Accepted
QGIS does not find existing column when drawing lines between two point layers
You miss the aliases for the layer names (q and z) and the points in the column names are interfering with the layer.column syntax.
Try this:
select q."q.id", z."z.id", makeline(q....
- 12.2k
10
votes
Accepted
QGIS - Countif function
This expression gives you what you need:
with_variable(
'ar', array(Attribute1, Attribute2, Attribute3, Attribute4),
array_length(@ar) - array_count(@ar, 0)
)
with_variable assigns the second ...
- 70k
1
vote
PostGIS - Reading geometry from a shapefile directly in the SQL query
With foreign data wrappers https://wiki.postgresql.org/wiki/Foreign_data_wrappers#Geo_Wrappers, yes. However, creating a fdw for a shapefile https://www.crunchydata.com/blog/querying-spatial-data-with-...
- 59k
Top 50 recent answers are included
Related Tags
sql × 1743postgis × 528
postgresql × 328
qgis × 312
arcgis-desktop × 199
arcpy × 145
query × 107
sql-server × 86
python × 83
carto × 81
enterprise-geodatabase × 80
geometry × 70
select-by-attribute × 68
arcmap × 61
oracle-dbms × 53
ogr2ogr × 51
spatialite × 50
shapefile × 41
ogr × 40
sqlite × 40
gdal × 37
polygon × 37
mapinfo × 37
geoserver × 36
virtual-layer × 36