3

newbie here of QGIS here, I was trying to aggregate a feature from a CSV with no geometries. The query is very basic:

SELECT 
    "PROV",
    SUM("POP_2012") AS POP_2012
FROM "municipalities-tuscany"
GROUP BY "PROV"

but I'm stuck and cannot make it work: if I go to Data Source Manager > Virtual Layer, fill the form and set Unique identifier column equal to PROV the resulting layer shows only 1 instance (instead of 10), like I filtered it. If I try using DB Manager > Virtual Layers and open the SQL Window, I run and correctly visualize the query, but when I try to Load as new layer, set Column with unique values equal to PROV and click Load nothing happens. If I set no Column with unique values get nothing in both cases.

  • Which version of QGIS are u using ? – snaileater Mar 11 '19 at 17:38
  • Using version 3.6 – gpapo Mar 13 '19 at 13:45
  • Did u solve your problem ? Are you able to share your file ? – snaileater Mar 13 '19 at 13:48
1

I think your unique identifier column is set on a wrong variable type (string ?) : it should be an integer ... Don't u have a specific numeric ID for your 'provinces' ?

| improve this answer | |
  • 2
    When you load a CSV into QGIS, it sometimes assumes every column is text. You can specify column type by creating a CSVT file, as explained here: anitagraser.com/2011/03/07/… – csk Mar 12 '19 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.