Skip to content

Commit

Permalink
Update documentation on creating reports
Browse files Browse the repository at this point in the history
  • Loading branch information
nassibnassar committed Jul 11, 2023
1 parent 8b11760 commit 6569fde
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions doc/User_Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ including the dates directly within the query, we will define them as
parameters: `start_date` and `end_date`.

```sql
CREATE FUNCTION local.lisa_count_loans(start_date date, end_date date)
RETURNS TABLE(item_id text, loan_count integer) AS
CREATE FUNCTION local.lisa_count_loans(
start_date date DEFAULT '2000-01-01',
end_date date DEFAULT '2050-01-01')
RETURNS TABLE(
item_id text,
loan_count integer) AS
$$
SELECT item_id,
count(*) AS loan_count
Expand All @@ -216,9 +220,9 @@ Now the function can be called with different arguments to generate
reports:

```sql
SELECT * FROM local.lisa_count_loans('2023-01-01', '2024-01-01');
SELECT * FROM local.lisa_count_loans(start_date => '2022-01-01', end_date => '2023-01-01');

SELECT * FROM local.lisa_count_loans('2022-01-01', '2023-01-01');
SELECT * FROM local.lisa_count_loans(start_date => '2023-01-01');
```

By default, all LDP users share the same user account, and all users
Expand Down Expand Up @@ -373,7 +377,7 @@ A lateral join can be used with the function `jsonb_array_elements()`
(or `json_array_elements()` for LDP 1.x) to convert the elements of a
JSON array to a set of rows, one row per array element.

For example, if the array elements are simple `varchar` strings:
For example, if the array elements are simple `text` strings:

```sql
CREATE TABLE local.example_array_simple AS
Expand Down

0 comments on commit 6569fde

Please sign in to comment.