CASE WHEN... AND in SQL ERROR
I'm working in MYSQL and trying to write a CASE WHEN Statement with multiple AND X<Y conditions. When it is finished, the statement below will be much longer with 15 more AND conditions, but right now this shorter version won't verify. The purpose of this statement is simply to find the lowest value across 15 columns for each row. Thoughts on what is going wrong (or perhaps a simplier way to find the minimum?? (The "min" function only finds the lowest value out of all the rows in the column (and not out of all the columns in a row, whic is what I'm trying to find). Thanks!
SELECT
CASE WHEN `Venturer_Dist`< `Strategist_Dist` AND `Venturer_Dist`< `Operator_Dist`
THEN 'Venturer'
END
FROM transform_data_3
Best Answer
-
Ok,
Try:
SELECT
CASE WHEN `Venturer_Dist`< `Strategist_Dist` AND `Venturer_Dist`< `Operator_Dist`
THEN 'Venturer' END AS ColumnName
FROM transform_data_3changes in Bold italic
If you are using this is a dataflow try also to loose the "`" :
SELECT
CASE WHEN Venturer_Dist < Strategist_Dist AND Venturer_Dist < Operator_Dist
THEN 'Venturer' END AS ColumnName
FROM transform_data_3Let me know how it goes.
Ricardo Granada
MajorDomo@Lusiaves
**If the post solves your problem, mark it by clicking on "Accept as Solution"
**You can say "Thank you" by clicking the thumbs up in the post that helped you.2
Answers
-
Hi,
What's the error?
Can/did you run transform_data_3 correctly?
Regards,
Ricardo Granada
MajorDomo@Lusiaves
**If the post solves your problem, mark it by clicking on "Accept as Solution"
**You can say "Thank you" by clicking the thumbs up in the post that helped you.0 -
Hi Ricardo,
This is the error message:
The database reported a syntax error. Incorrect column name 'CASE WHEN `Venturer_Dist`< `Strategist_Dist` AND `Venturer_Dist`< `Operator_Dist` THEN 'Venturer' E'
transform_data_3 is running smoothly!
Thanks,
Sarah
0 -
Ok,
Try:
SELECT
CASE WHEN `Venturer_Dist`< `Strategist_Dist` AND `Venturer_Dist`< `Operator_Dist`
THEN 'Venturer' END AS ColumnName
FROM transform_data_3changes in Bold italic
If you are using this is a dataflow try also to loose the "`" :
SELECT
CASE WHEN Venturer_Dist < Strategist_Dist AND Venturer_Dist < Operator_Dist
THEN 'Venturer' END AS ColumnName
FROM transform_data_3Let me know how it goes.
Ricardo Granada
MajorDomo@Lusiaves
**If the post solves your problem, mark it by clicking on "Accept as Solution"
**You can say "Thank you" by clicking the thumbs up in the post that helped you.2 -
The first solution worked! Thanks for your help!
1
Categories
- All Categories
- 1.7K Product Ideas
- 1.7K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 294 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.8K Transform
- 97 SQL DataFlows
- 607 Datasets
- 2.1K Magic ETL
- 3.8K Visualize
- 2.4K Charting
- 707 Beast Mode
- 49 App Studio
- 39 Variables
- 667 Automate
- 170 Apps
- 446 APIs & Domo Developer
- 44 Workflows
- 7 DomoAI
- 33 Predict
- 13 Jupyter Workspaces
- 20 R & Python Tiles
- 391 Distribute
- 111 Domo Everywhere
- 274 Scheduled Reports
- 6 Software Integrations
- 115 Manage
- 112 Governance & Security
- Domo Community Gallery
- 31 Product Releases
- 9 Domo University
- 5.3K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 103 Community Announcements
- 4.8K Archive