0
I need to select an audience within some constraints.
The first 3 lines of the
GRUPO 1
The first line of
GRUPO 3
In case you don’t have first line on
GRUPO 3
:The first line of
GRUPO 4
The first line of
GRUPO 2
If you don’t have the first line of
GRUPO 4
So instead of selecting only the first line ofGRUPO 2
, shall select 2 lines.
I’m trying to rank and catch it with case when
, but it’s complicated. Somebody help me?
Thank you.
I have a public table in the following format:
CLIENT | GROUP | RANK |
---|---|---|
100 | 1 | 1 |
101 | 1 | 2 |
102 | 1 | 3 |
103 | 1 | 4 |
104 | 1 | 5 |
105 | 2 | 1 |
106 | 2 | 2 |
107 | 2 | 3 |
108 | 2 | 4 |
109 | 4 | 1 |
110 | 4 | 2 |
Final Table Caught the top 3 of GRUPO 1
, the first line of GRUPO 4
and the first of GRUPO 2
CLIENT | GROUP | RANK |
---|---|---|
100 | 1 | 1 |
101 | 1 | 2 |
102 | 1 | 3 |
109 | 4 | 1 |
105 | 2 | 1 |
welcome Juliana. Read your question and try to think of people who do not know the tables, the fields, nothing, there is no help. Ask the query and data model you already have, and an example of the expected result
– Ricardo Pontual
Would making the UNION of selects with due conditions not be a better approach than with CASE/WHEN?
– anonimo
Which one of yours
SGBD
? Can you put in your question thescript
table creation and data insertion?– Sorack