Skip to content
Advertisement

SQL query with multiple same conditions

I work with Sybase DB and trying to select data using few conditions:

The table name “alias”.


I have few conditions:

So the result should be a_data = 666, in case the both conditions are achived. The query should be like this, but it, of course, does not work, returns 0 results:

Expecting result a_data = 666.

Can someone advise something workaround? It is possible to have 2, 3 or more conditions like above.

Advertisement

Answer

Use aggregation and having:

Note: This assumes that type/value pairs are not duplicated in the original data for a given a_data value. If they can be, then use:

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