วันที่ที่สอดคล้องกันใน transaction
สำนักงานภาคสนามไอดาโฮกลับมาอีกครั้ง และต้องการเปรียบเทียบตัวอย่างล่าสุด 10 รายการระหว่างไซต์ทดสอบหมายเลข 13903 ในเขต Minidoka ที่เราวิเคราะห์อยู่ กับไซต์หมายเลข 11643 ในเขต Ada
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Introduction to Redshift
คำแนะนำการฝึกหัด
- เปิด transaction
- ใช้ฟังก์ชันที่เหมาะสมเพื่อให้ได้ timestamp เดิม และปิดคำสั่ง SELECT ทั้งสองให้ถูกต้อง
- ปิด transaction
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
--Open the Transaction
___
SELECT *, CAST(sample_date AS DATE) as date_sampled
FROM public_intro_redshift.idaho_samples
WHERE fk_monitoringlocation = 13903
-- Use the consistent timestamp function
AND CAST(sample_date AS DATE) < ___
ORDER BY date_sampled DESC
-- Add the statement terminator
LIMIT 10___
SELECT *, CAST(sample_date AS DATE) as date_sampled
FROM public_intro_redshift.idaho_samples
WHERE fk_monitoringlocation = 11643
-- Use the consistent timestamp function
AND CAST(sample_date AS DATE) < ___
ORDER BY date_sampled DESC
-- Add the statement terminator
LIMIT 10___
-- Close the transaction
___