Help needed with n1ql query


#1

Here is a snippet of my doc structure,
I would like to select pickerQuantity where any value in productKeys.alt[] matches “123p”, so in that case it should return 4

{
    "docType": "design",
    "eventDescription": "",
    "eventId": "e-id-1",
    "eventTitle": "e-title",
    "screenLayout": {
        "webApp": {
            "sections": [
                {
                    "columns": [],
                    "pickerQuantity": 4,
                    "rows": [
                        {
                            "productKeys": {
                                "alt": [
                                    "123p",
                                    "123p2"
                                ],
                                "test": [
                                    "123t"
                                ]
                            },
                            "title": "123 title"
                        },
                        {
                            "productKeys": {
                                "alt": [
                                    "456p"
                                ],
                                "test": [
                                    "456t"
                                ]
                            },
                            "title": "456 title"
                        }
                    ],
                    "sectionTitle": "section title"
                },
                {
                    "columns": [],
                    "pickerQuantity": 9,
                    "rows": [
                        {
                            "productKeys": {
                                "alt": [
                                    "789p"
                                ],
                                "test": [
                                    "789t"
                                ]
                            },
                            "title": "789 title"
                        }
                    ],
                    "sectionTitle": "section title"
                }
            ]
        }
    }
}

#2

FYI

SELECT s.pickerQuantity
  FROM default d 
UNNEST d.screenLayout.webApp.sections AS s 
UNNEST s.rows AS r
 WHERE d.docType == "design"
   AND ANY a IN r.productKeys.alt SATISFIES a == "789p" END