Returns the leftmost n characters of a string.
Syntax
LEFT(str, n)Example
Enter values below to update the example in real time.
product_code→category_code→cnt→products→-- 제품 코드 앞 3자리로 카테고리 구분
SELECT LEFT(product_code, 3) AS category_code, COUNT(*) AS cnt
FROM products
GROUP BY category_code;