Grupları karşılaştırma

SQL ile Raporlama

Tyler Pernes

Learning & Development Consultant

Metrik türleri

  • Hacim metrikleri
  • Verimlilik metrikleri
SQL ile Raporlama

Hacim metrikleri

  • Büyüklükle ölçeklenir
SQL ile Raporlama

Hacim metrikleri

  • Büyüklükle ölçeklenir

SQL ile Raporlama

Hacim metrikleri

  • Büyüklükle ölçeklenir

SQL ile Raporlama

Toplamın yüzdesi hesabı

basketball_points tablosu
+----------+------------+---------+
| team_id  | player_id  | points  |
|----------|------------|---------|
| 1        | 482        | 92      |
| 1        | 165        | 47      |
| 2        | 222        | 64      |
+----------+------------+---------+
SELECT team_id, SUM(points) AS points
FROM basketball_points
GROUP BY team_id;
SQL ile Raporlama

Toplamın yüzdesi hesabı

basketball_points tablosu
+----------+------------+---------+
| team_id  | player_id  | points  |
|----------|------------|---------|
| 1        | 482        | 92      |
| 1        | 165        | 47      |
| 2        | 222        | 64      |
+----------+------------+---------+
+----------+---------+
| team_id  | points  |
|----------|---------|
| 1        | 782     |
| 2        | 625     |
| 3        | 487     |
| 4        | 398     |
+----------+---------+
SQL ile Raporlama

Toplamın yüzdesi hesabı

Adım 1: Toplamı hesaplayın

SELECT 
    team_id, 
    SUM(points) AS points
    SUM(points) OVER () AS total_points
FROM basketball_points
GROUP BY team_id;

Adım 2: Toplamın yüzdesini hesaplayın

SELECT 
    team_id, 
    SUM(points) AS points
    SUM(points) / SUM(points) OVER () AS perc_of_total
FROM basketball_points
GROUP BY team_id;
SQL ile Raporlama

Toplamın yüzdesi hesabı

Sonuçlar:

+----------+---------+---------------+
| team_id  | points  | perc_of_total |
|----------|---------|---------------|
| 1        | 782     | .34           |
| 2        | 625     | .27           |
| 3        | 487     | .21           |
| 4        | 398     | .17           |
+----------+---------+---------------+
SQL ile Raporlama

Toplamın yüzdesi hesabı

Her takım için oyuncu başına puanların yüzdesi:

SELECT 
    player_id,
    team_id,
    SUM(points) AS points
    SUM(points) / (SUM(points) OVER (PARTITION BY team_id)) AS perc_of_team
FROM basketball_points
GROUP BY player_id, team_id;
SQL ile Raporlama

Toplamın yüzdesi hesabı

Sonuçlar:

+-----------+---------+---------+--------------+
| player_id | team_id | points  | perc_of_team |
|-----------|---------|---------|--------------|
| 482       | 1       | 92      | .12          |
| 165       | 1       | 47      | .06          |
| 222       | 2       | 64      | .10          |
+-----------+---------+---------+--------------+
SQL ile Raporlama

Verimlilik metrikleri

  • Büyüklükle ölçeklenmez
  • Genelde bir oran
SQL ile Raporlama

Verimlilik metrikleri

  • Büyüklükle ölçeklenmez
  • Genelde bir oran

SQL ile Raporlama

Verimlilik metrikleri

  • Büyüklükle ölçeklenmez
  • Genelde bir oran

SQL ile Raporlama

Performans endeksi

  • Performansı bir kıyasla karşılaştırır
  • Kıyas genelde ortalama veya medyandır
SQL ile Raporlama

Performans endeksi

basketball_summary tablosu
+----------+--------+---------+
| team_id  | games  | points  |
|----------|--------|---------|
| 1        | 24     | 782     |
| 2        | 20     | 625     |
| 3        | 12     | 487     |
+----------+--------+---------+
  • Maç başına puan performansı?
SQL ile Raporlama

Performans endeksi

Adım 1: Her takım için maç başına puan

SELECT 
    team_id, 
    points/games AS team_ppg
FROM basketball_summary;

Adım 2: Lig genelinde maç başına puan

SELECT 
    team_id, 
    points/games AS team_ppg,
    SUM(points) OVER () / SUM(games) OVER () AS league_ppg
FROM basketball_summary;
SQL ile Raporlama

Performans endeksi

Adım 3: Performans endeksi

SELECT 
    team_id, 
    points/games AS team_ppg,
    SUM(points) OVER () / SUM(games) OVER () AS league_ppg,
    (points/games) 
    / 
    (SUM(points) OVER () / SUM(games) OVER ()) AS perf_index
FROM basketball_summary;
SQL ile Raporlama

Performans endeksi

Adım 3: Performans endeksi

+----------+----------+------------+-------------+
| team_id  | team_ppg | league_ppg | perf_index  |    
|----------|----------|------------|-------------|
| 1        | 32.6     | 33.8       | 0.96        |
| 2        | 31.3     | 33.8       | 0.92        |
| 3        | 40.6     | 33.8       | 1.20        |
+----------+----------+------------+-------------+
1 Sonuçlar, üçüncü takımın lig ortalamasından %20 daha fazla puan aldığını açıkça gösteriyor.
SQL ile Raporlama

Sorgu zamanı!

SQL ile Raporlama

Preparing Video For Download...