在 SQL Server 中使用函数处理数据
Ana Voicu
Data Engineer
请记住:比较两个值时,它们必须同类型。
否则:
SELECT
company
bean_type,
cocoa_percent
FROM ratings;
SELECT
company
bean_type,
cocoa_percent
FROM ratings
WHERE cocoa_percent > 0.5;
| company | bean_type | cocoa_percent |
|---------|------------|---------------|
| Amedei | Blend | 0.7000 |
| Bonnat | Trinitario | 0.7500 |
| ... | ... | ... |
SELECT
company
bean_type,
cocoa_percent
FROM ratings
WHERE cocoa_percent > -2;
| company | bean_type | cocoa_percent |
|---------|------------|---------------|
| Amedei | Blend | 0.7000 |
| Bonnat | Trinitario | 0.7500 |
| ... | ... | ... |
SELECT
company
bean_type,
cocoa_percent
FROM ratings
WHERE cocoa_percent > GETDATE();
| company | bean_type | cocoa_percent |
|---------|------------|---------------|
| ... | ... | ... |
SELECT
company
bean_type,
cocoa_percent
FROM ratings
WHERE cocoa_percent > 'A';
| result |
|------------------------------------------------|
| Error converting data type varchar to numeric. |
SELECT
company
bean_type,
cocoa_percent
FROM ratings
WHERE cocoa_percent > '0.5';
| company | bean_type | cocoa_percent |
|---------|------------|---------------|
| Amedei | Blend | 0.7000 |
| Bonnat | Trinitario | 0.7500 |
| ... | ... | ... |
在 SQL Server 中使用函数处理数据