Skip to content
Advertisement

Alternative to CASE Statement to Compare and Summarize Data

I have a database that looks like the following;

I need to compare the values from each price column and count the matched and mismatched prices and summarize as follows:

Required Results

I can do this via multiple case statements (below) but I’m wondering if there is a better approach.

Current Code:

Advertisement

Answer

I am guessing from your recent questions, you’re using Snowflake, in which case you can use a more compact syntax. I still think using case expression is better from a documentation and portability standpoint;

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement