D
D
Denis Lvov2019-06-21 23:06:06
SQL
Denis Lvov, 2019-06-21 23:06:06

ORDER BY .. HAVING or "complex" sorting?

I have a hat like this:
5d0d379a46758114308519.png
The problem is this:
linkedid is a unique number.
If Answered is in disposition, then it should be left, and No answer should be discarded.
If linkedid is one and in disposition - No answer, then we also leave

Thought on GROUP BY .. HAVING, but it doesn't even work.
Please tell me which direction to go

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lazy @BojackHorseman, 2019-06-22
@dwenlvov

SELECT *,
    ROW_NUMBER() OVER(PARTITION BY linkedid ORDER BY disposition) AS row_num 
FROM <tablename>
WHERE row_num = 1

A
Alexander Aksentiev, 2019-06-22
@Sanasol

You can’t group telephony logs normally, there are a million different variations and the data arrives in random order often.
We need a full-fledged script with logic that processes this mess in the table and writes down some final version for each call.

B
Boris Korobkov, 2019-06-22
@BorisKorobkov

As an option: JOIN on itself by linkedid with the necessary conditions for the first disposition and the second.
But if there are a lot of records, it will slow down.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question