Functions for Manipulating Data in SQL Server
Ana Voicu
Data Engineer
Keep in mind: for comparing two values, they need to be of the same type.
Otherwise:
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 |
| ... | ... | ... |
Functions for Manipulating Data in SQL Server