SQL Reference

이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Overview

SQL in Analysis cells allows you to analyze and manipulate data within Log Workspaces. This documentation covers the SQL support available in Log Workspaces and includes:

Example workspace cell with SQL syntax

Syntax

The following SQL syntax is supported:

SyntaxDescriptionExample
SELECT (DISTINCT)
DISTINCT: Optional
Retrieves rows from a database, with DISTINCT filtering out duplicate records.
SELECT DISTINCT customer_id 
FROM orders 
JOINCombines rows from two or more tables based on a related column between them.
SELECT orders.order_id, customers.customer_name 
FROM orders 
JOIN customers 
ON orders.customer_id = customers.customer_id 
GROUP BYGroups rows that have the same values in specified columns into summary rows.
SELECT product_id, SUM(quantity) 
FROM sales 
GROUP BY product_id 
WHERE
Includes support for LIKE filters on strings for pattern matching.
Filters records that meet a specified condition.
SELECT * 
FROM employees 
WHERE department = 'Sales' AND name LIKE 'J%' 
CASEProvides conditional logic to return different values based on specified conditions.
SELECT order_id, 
  CASE 
    WHEN quantity > 10 THEN 'Bulk Order' 
    ELSE 'Standard Order' 
  END AS order_type 
FROM orders 
Arithmetic OperationsPerforms basic calculations using operators like +, -, *, /.
SELECT price, tax, (price * tax) AS total_cost 
FROM products 

Functions

The following SQL functions are supported:

FunctionDescriptionExample
MINReturns the smallest value in a set of data.
SELECT MIN(response_time) AS min_response_time 
FROM logs 
WHERE status_code = 200 
MAXReturns the maximum value across all input values.
SELECT MAX(response_time) AS max_response_time 
FROM logs 
WHERE status_code = 200 
COUNTReturns the number of input values that are not null.
SELECT COUNT(request_id) AS total_requests 
FROM logs 
WHERE status_code = 200 
SUMReturns the summation across all input values.
SELECT SUM(bytes_transferred) AS total_bytes 
FROM logs 
GROUP BY service_name 
AVGReturns the average value (arithmetic mean) across all input values.
SELECT AVG(response_time) 
AS avg_response_time 
FROM logs 
WHERE status_code = 200 
GROUP BY service_name 
CEIL/CEILING(numerical column)Returns the value rounded up to the nearest integer.
 SELECT CEIL(price) AS rounded_price 
FROM products 
FLOORReturns the value rounded down to the nearest integer.
SELECT FLOOR(price) AS floored_price 
FROM products 
ROUNDReturns the value rounded to the nearest integer.
SELECT ROUND(price) AS rounded_price 
FROM products 
LOWERReturns the string as lower case.
SELECT LOWER(customer_name) AS lowercase_name 
FROM customers 
UPPERReturns the string as uppercase.
SELECT UPPER(customer_name) AS uppercase_name 
FROM customers 
ABSReturns the absolute value.
SELECT ABS(balance) AS absolute_balance 
FROM accounts 
COALESCEReturns the first non-null value.
SELECT COALESCE(phone_number, email) AS contact_info 
FROM users 

Further reading

추가 유용한 문서, 링크 및 기사:

PREVIEWING: mervebolat/span-id-preprocessing