Question: Please help - I have a problem with enabling billing permissions in my expo app (managed workflow). When i build app bundle `expo build:android -t app-bundle` and submit it to google, google said that too many permissions - all permissions were enabled, which is insane.
I removed all - added "permissions": [] to app.json, but after that google says that I have to enable billing permissions in order to add in-app purchases.

I've tried to specify "com.android.vending.BILLING" permission, but Google doesn't accept it - it says *We've detected this app uses an unsupported version of Play billing. Please upgrade to Billing Library version 3 or newer to publish this app.* Removing this permission helped to get red of the error, but google still doesn't allow to add any in-app product on google play, it says *'To add in-app products, you need to add the BILLING permission to your APK'*

I tried to add `<meta-data android:name="com.google.android.play.billingclient.version" android:value="3.1.0" />` to AndroidManifest.xml but it didn't help either

P.S "expo-in-app-purchases": "^13.1.0" package installed

Answer: 
An alternative approach using the cool function [ARRAY\_AGG()](https://docs.snowflake.com/en/sql-reference/functions/array_agg.html).

[![enter image description here](https://i.stack.imgur.com/daU0d.png)](https://i.stack.imgur.com/daU0d.png)

```
SELECT   
  TRANSACTION_ID
, TRANSACTION_TYPE
, ARRAY_TO_STRING("'CA'",',') CA
, ARRAY_TO_STRING("'MA'",',') MA
, ARRAY_TO_STRING("'NY'",',') NY
FROM   
    T1
PIVOT (ARRAY_AGG(T1.DATE_TIMESTAMP) FOR T1.STATE IN ('CA','MA','NY'));

```

where T1 was lifted from Felipe's excellent answer.

```
with t1 as (
select transaction_id, state, transaction_type, date_timestamp
from (
    select split(value, '|') x, trim(x[0])  transaction_id, trim(x[1]) state, trim(x[2]) transaction_type, x[3]::string::timestamp date_timestamp
    from table(split_to_table(
    $$      1      |   CA   |     Payment      |   12/1/2022 01:00:00
            1      |   CA   |     Payment      |   12/1/2022 02:00:00
            1      |   MA   |     Payment      |   12/1/2022 01:00:00
            2      |   MA   |     Refund       |   12/1/2022 01:00:00
            3      |   NY   |     Payment      |   12/1/2022 01:00:00
            4      |   MA   |     Payment      |   12/1/2022 03:00:00$$, '\n'))
)
)

```
Try with an explicit pivot operation:

```
SELECT transaction_id, 
       transaction_type,
       LISTAGG(CASE WHEN state = 'CA' THEN date_timestamp END, ', ') AS CA,
       LISTAGG(CASE WHEN state = 'NY' THEn date_timestamp END, ', ') AS NY,
       LISTAGG(CASE WHEN state = 'MA' THEn date_timestamp END, ', ') AS MA
FROM tab
GROUP BY transaction_id,
         transaction_type

```