cubes icon indicating copy to clipboard operation
cubes copied to clipboard

Cut string to generate sql statement that contains OR clause on different columns

Open cuipengfei opened this issue 9 years ago • 4 comments

Hello everyone,

I read in the documentation that we can use cut string like: ...?cut=a:1|b:2 to generate sql statements that contains "where a=1 and b=2"

And we can use ; like this: ...?cut=a:1;2 to generate sql statements that contains "where a=1 or a=2"

How can I write a cut string that would generate sql like this? SELECT x, y, z FROM A LEFT JOIN B ON A.id = B.idOfA WHERE B.someColumn = 'something' OR B.someOtherColum = 'something else';

As we can see the where clause is concerned about 2 different columns, I have not found a way to do this in the doc.

Is this achievable?

cuipengfei avatar Dec 09 '15 07:12 cuipengfei

Hi, is there a solution for this?

cuipengfei avatar Mar 17 '16 05:03 cuipengfei

You would need to do this in two separate queries, and combine the results.

OLAP queries are not normally well suited for this: once you add the possibility that a single fact is selected by two different criteria, the behavior of aggregates is not well defined.

Perhaps there's other way of doing what you want. What is your use case exactly?

jjmontesl avatar May 29 '16 05:05 jjmontesl

Hello @jjmontesl

I'm also interested in making queries using the OR clause.

Could you explain the reason you gave? I have tried to find documentation about it and I have not found any information that discourages the use of OR in OLAP.

Thanks in advance.

pablolmedorado avatar May 29 '18 20:05 pablolmedorado

In version 1.1 it supports this feature. Syntax is just what @cuipengfei has suggested.

ThamaluM avatar Nov 30 '19 15:11 ThamaluM