Skip to Content
author's profile photo Former Member
Former Member

CASE WHEN equivalent in SQLSCRIPT

Hello everybody,

I am new to this forum, maybe somebody can help me

At it's core, I want to create a calculation view that calculates count() of different values for one column

in SQL, I was able to solve the problem with the following code:

SELECT "Id", count(case when "TA_TYPE"='StrongPositiveSentiment' then 1 end) as "SPS",

count(case when "TA_TYPE"='WeakPositiveSentiment' then 1 end) as "WPS",

count(case when "TA_TYPE"='Sentiment' then 1 end) as "S",

count(case when "TA_TYPE"='WeakNegativeSentiment' then 1 end) as "WNS",

count(case when "TA_TYPE"='StrongNegativeSentiment' then 1 end) as "SNS"

FROM "GBI_011"."$TA_GRUPPE_3_ENGLISH_IDX"

GROUP BY "Id"


The corresponding output looks like this:




Now, I want to create the same in a calculation view with SQLScript, but it seems the same code doesnt work there. I want to group by "Id" and get the count() values for different entries in "TA_TYPE", e.g Sentiment, WeakPositiveSentiment etc... in the calculation view


any suggestions? I hope I made my problem clear


Greetings

Daniel


hana.PNG (9.4 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 07, 2016 at 08:42 PM

    Hi Daniel,

    What you mean by 'it seems the same code doesn't work there'? I can't see why it wouldn't work but is there any error message you're facing?

    Maybe post your actual sqlscript code so we can look at it. If you have some small sample data that helps even further.

    BRs,

    Lucas de Oliveira

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.