Skip to content

SQL from an each loop #2636

Answered by archiewood
scottincrypto asked this question in Q&A
Discussion options

You must be logged in to vote

The best solution here is very close to your solution, but using a SQL filter in the loop, not JS

```sql query_output
select distinct filter_col
from my_table
```

```sql table_for_chart
select xval, yval, filter_col 
from my_table
```

{#each query_output as item}

### Chart of {item.filter_col}

<LineChart
  data={query_output.where(`filter_col = ${item.filter_col}`)}
  x=xval
  y=yval
/>

{/each}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@fmdallas
Comment options

Answer selected by archiewood
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants