Pengantar SQL Server
John MacKintosh
Instructor


SQL Server - sistem basis data relasional dari Microsoft
Transact-SQL (T-SQL) - implementasi SQL oleh Microsoft, dengan fitur tambahan
Di kursus ini: Kuasai dasar-dasar T-SQL
Pelajari cara menulis kueri

SQL Server: “toko” yang menyimpan basis data dan tabel
Kueri: cara kita “memilih” item dari berbagai lorong dan memasukkannya ke keranjang
SELECT: istilah kunci untuk mengambil data

SELECT description
FROM grid;
+-------------------------------------+
| description |
|-------------------------------------|
| Severe Weather Thunderstorms |
| Severe Weather Thunderstorms |
| Severe Weather Thunderstorms |
| Fuel Supply Emergency Coal |
| Physical Attack Vandalism |
| Physical Attack Vandalism |
| Physical Attack Vandalism |
| Severe Weather Thunderstorms |
| Severe Weather Thunderstorms |
| Suspected Physical Attack |
| Physical Attack Vandalism |
| ... |
+-------------------------------------+
SELECT
artist_id,
artist_name
FROM
artist;
+-----------+----------------------+
| artist_id | artist_name |
|-----------+----------------------|
| 1 | AC/DC |
| 2 | Accept |
| 3 | Aerosmith |
| 4 | Alanis Morissette |
| 5 | Alice In Chains |
| 6 | Antônio Carlos Jobim |
| 7 | Apocalyptica |
| 8 | Audioslave |
| 9 | BackBeat |
| 10 | Billy Cobham |
+-----------+----------------------+
SELECT description, event_year, event_date
FROM grid;
SELECT
description,
event_year,
event_date
FROM
grid;
-- Kembalikan 5 baris
SELECT TOP(5) artist
FROM artists;
-- Kembalikan 5% baris teratas
SELECT TOP(5) PERCENT artist
FROM artists;
+-----------------------+
| artist |
|-----------------------|
| AC/DC |
| Accept |
| Aerosmith |
| Alanis Morissette |
| Alice in Chains |
+-----------------------+
-- Kembalikan semua baris di tabel
SELECT nerc_region
FROM grid;
+-------------+
| nerc_region |
|-------------|
| RFC |
| RFC |
| MRO |
| MRO |
| .... |
+-------------+
-- Kembalikan baris unik
SELECT DISTINCT nerc_region
FROM grid;
+-------------+
| nerc_region |
|-------------|
| NPCC |
| NPCC RFC |
| RFC |
| ERCOT |
| ... |
+-------------+
-- Kembalikan semua baris
SELECT *
FROM grid;
SELECT demand_loss_mw AS lost_demand
FROM grid;
+-------------+
| lost_demand |
|-------------|
| 424 |
| 217 |
| 494 |
| 338 |
| 3900 |
| 3300 |
+-------------+
SELECT description AS cause_of_outage
FROM grid;
+------------------------------+
| cause_of_outage |
|------------------------------|
| Severe Weather Thunderstorms |
| Fuel Supply Emergency Coal |
| Physical Attack Vandalism |
| Suspected Physical Attack |
| Electrical System Islanding |
+------------------------------+
Pengantar SQL Server