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.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive