R
R
raswe2020-05-07 11:28:06
SQL
raswe, 2020-05-07 11:28:06

Select non-duplicate records from SQL table?

Good afternoon!
There is a table listing customers ID_CUSTOMERS and the start and end dates of their orders.
There are such customers in the table that have only one row - i.e. they only had 1 order. And there are those - who have two and three and ten.
The task is to make a selection of those records that have only one order in a certain time range.

I tried Distinct, it doesn't work, because it just shows one entry, although in fact there may be more. And here it is necessary that it is those who got into the result, who have strictly one record for the specified period.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stimulate, 2020-05-07
@raswe

HAVING COUNT(`field`)=1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question