शुरू करेंमुफ़्त में शुरू करें

CTEs के साथ डेटा फ़िल्टर करना

CTE का एक प्रभावी उपयोग यह है कि आप क्वेरी के आगे इस्तेमाल करने से पहले CTE में ही डेटा फ़िल्टर कर लें. इससे अंतिम क्वेरी में कम डेटा आता है और कुल लागत घटती है. यह क्वेरी उन ऑर्डर्स का order status ढूँढने में मदद करेगी जिनके आइटम्स की कीमत $150 से अधिक है.

यह अभ्यास पाठ्यक्रम का हिस्सा है

BigQuery परिचय

पाठ्यक्रम देखें

अभ्यास निर्देश

  • एक नया CTE orders बनाएँ जो $150 से अधिक कीमत वाले ऑर्डर्स चुने, इसके लिए order_items को UNNEST करके price कॉलम पाएँ.
  • CTE के परिणामों को ecomm_order_details डेटासेट से JOIN करें ताकि order_status की संख्या मिले और हर status में ऑर्डर्स को COUNT करके एग्रीगेट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

-- Add the correct items to finish our filtered CTE

-- Create a new CTE with the name orders
WITH ___ AS (
  SELECT order_id
  -- Add the correct column for the order item details
  FROM ecommerce.ecomm_orders, UNNEST(___) items
  -- Fill in the correct column for the item price 
  WHERE items.___ > 150
)

SELECT
	-- Aggregate to find the total number of orders
	___(order_id),
	-- Add the column for the status of the order
	___
FROM ecommerce.ecomm_order_details od
JOIN orders o USING (order_id)
GROUP BY order_status
कोड संपादित करें और चलाएँ