BaşlayınÜcretsiz Başlayın

Creating CTEs (I)

A Common table expression or CTE is used to create a table that can later be used with a query. To create a CTE, you will always use the WITH keyword followed by the CTE name and the name of the columns the CTE contains. The CTE will also include the definition of the table enclosed within the AS().

In this exercise, you will use a CTE to return all the ages with the maximum BloodGlucoseRandom in the table.

Bu egzersiz

Intermediate SQL Server

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a CTE BloodGlucoseRandom that returns one column (MaxGlucose) which contains the maximum BloodGlucoseRandom in the table.
  • Join the CTE to the main table (Kidney) on BloodGlucoseRandom and MaxGlucose.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

-- Specify the keyowrds to create the CTE
___ BloodGlucoseRandom (MaxGlucose) 
___ (SELECT MAX(BloodGlucoseRandom) AS MaxGlucose FROM Kidney)

SELECT a.Age, b.MaxGlucose
FROM Kidney a
-- Join the CTE on blood glucose equal to max blood glucose
JOIN BloodGlucoseRandom b
___
Kodu Düzenle ve Çalıştır