MulaiMulai sekarang secara gratis

Slide to the right

Now let's see how FC Utrecht performs when they're the away team. You'll notice that the total for the season is at the bottom of the data set you queried. Depending on your results, this could be pretty long, and scrolling down is not very helpful.

In this exercise, you will slightly modify the query from the previous exercise by sorting the data set in reverse order and calculating a backward running total from the CURRENT ROW to the end of the data set (earliest record).

Latihan ini adalah bagian dari kursus

Data Manipulation in SQL

Lihat Kursus

Petunjuk latihan

  • Complete the window function by:
    • Assessing the running total of away goals scored by FC Utrecht.
    • Assessing the running average of away goals scored.
    • Ordering both the running average and running total by date, descending.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

SELECT
    -- Select the date and away goals
    ___,
    ___,
    -- Create a running total sum and running average of away goals
    ___(away_goal) ___(ORDER BY ___ DESC
         ROWS BETWEEN ___ ___ AND ___ ___) AS running_total,
    ___(away_goal) ___(ORDER BY ___ DESC
         ROWS BETWEEN ___ ___ AND ___ ___) AS running_avg
FROM match
WHERE 
	awayteam_id = 9908 
    AND season = '2011/2012';
Edit dan Jalankan Kode