Skip to content

Commit 5a6b4b3

Browse files
authored
Updated SQL query INDEX_OF code samples
1 parent 52b838d commit 5a6b4b3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

articles/cosmos-db/sql/sql-query-index-of.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,24 @@ INDEX_OF(<str_expr1>, <str_expr2> [, <numeric_expr>])
4040
The following example returns the index of various substrings inside "abc".
4141

4242
```sql
43-
SELECT INDEX_OF("abc", "ab") AS i1, INDEX_OF("abc", "b") AS i2, INDEX_OF("abc", "c") AS i3
43+
SELECT
44+
INDEX_OF("abc", "ab") AS index_of_prefix,
45+
INDEX_OF("abc", "b") AS index_of_middle,
46+
INDEX_OF("abc", "c") AS index_of_last,
47+
INDEX_OF("abc", "d") AS index_of_missing
4448
```
4549

4650
Here is the result set.
4751

4852
```json
49-
[{"i1": 0, "i2": 1, "i3": -1}]
53+
[
54+
{
55+
"index_of_prefix": 0,
56+
"index_of_middle": 1,
57+
"index_of_last": 2,
58+
"index_of_missing": -1
59+
}
60+
]
5061
```
5162

5263
## Next steps

0 commit comments

Comments
 (0)