Skip to content

Commit ea91a75

Browse files
Update cost-per-query-in-snowflake-using-credits_attributed_compute-metric-in-query_attribution_history-view.md
1 parent 156644d commit ea91a75

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cost-per-query-in-snowflake-using-credits_attributed_compute-metric-in-query_attribution_history-view.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ select
1919
, avg(credits_attributed_compute)
2020
, max(credits_attributed_compute)
2121
, min(credits_attributed_compute)
22+
, count(*) as number_of_executions
2223
, left(any_value(query_history.query_text), 80) as query_text
2324
from SNOWFLAKE.ACCOUNT_USAGE.QUERY_ATTRIBUTION_HISTORY
24-
inner join SNOWFLAKE.ACCOUNT_USAGE.query_history using (query_parameterized_hash)
25-
group by all;
26-
order by credits_attributed_compute desc;
25+
inner join SNOWFLAKE.ACCOUNT_USAGE.query_history using (query_parameterized_hash, start_time)
26+
group by all
27+
order by number_of_executions desc;
2728
```
2829

29-
|![carbon(10)](https://github.com/user-attachments/assets/f7661c5a-b1c0-43b5-a501-ba818a414358)|
30+
|![carbon(11)](https://github.com/user-attachments/assets/40a2dec0-e5f0-4294-946d-567996b4bf4b)|
3031
|:-:|
3132
|Using `query_parameterized_hash` to JOIN `QUERY_ATTRIBUTION_HISTORY` and `QUERY_HISTORY` |
3233

0 commit comments

Comments
 (0)