Is this an array or a list and how do I access a specific element? (SQL)

While this question may initially sound like a question you’d see on sites like stackoverflow, I’ve been genuinly looking for an answer for almost an hour.

in my ERPNext-instance, I can execute the following statement:

select item_code, stock_queue, `tabStock Entry`.posting_date from `tabStock Entry` left join `tabStock Ledger Entry` on `tabStock Ledger Entry`.voucher_no = `tabStock Entry`.name where item_code like "10121034

This will result in this output:

| item_code | stock_queue    | posting_date |
| 101210341 | [[1.0, 228.4]] | 2019-08-07   |
1 row in set (0.00 sec)

As you can see “stock_queue” consists of a list or an array of 2 float numbers. How do I access the first value? I tried several things, including adding a [0] or (1) in my select query, but it just returns a syntax error. Meaning, I’m stuck right now. Any help would be appreciated!

It’s a list of tuples. Since data type of this field is string thus you can’t access directly using list index.

However, you can try using below ref:

1 Like