We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e0bc429 commit 8f59ff6Copy full SHA for 8f59ff6
datacamp/data_manipulation_in_snowflake.md
@@ -204,8 +204,25 @@ ORDER BY avg_track_length DESC;
204
```
205
206
## Finding the most efficient composer
207
-```
+```sql
208
+-- Create a CTE called track_metrics, convert milliseconds to seconds
209
+WITH track_metrics AS (
210
+ SELECT
211
+ composer,
212
+ milliseconds / 1000 AS num_seconds,
213
+ unit_price
214
+ FROM store.track
215
+ -- Retrieve records where composer is not NULL
216
+ WHERE composer IS NOT NULL
217
+)
218
219
+SELECT
220
221
+ -- Find the average price-per-second
222
+ AVG(unit_price / num_seconds) AS cost_per_second
223
+FROM track_metrics
224
+GROUP BY composer
225
+ORDER BY cost_per_second DESC;
226
227
228
## Where are customers buying?
0 commit comments