1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Get Records between dates and exist at least 3 times

Discussão em 'Outras Linguagens' iniciado por Stack, Setembro 10, 2024.

  1. Stack

    Stack Membro Participativo

    I have table with over 35 million email records.

    I need to get all of the records between a date range and also exist at least 3 times in the table.

    1 email may have more than one property but will never have the same property twice.

    The table looks like this:

    EMAIL PROPERTY LAST_SENT_DATE
    email1 prop1 2024-06-25
    email2 prop1 2024-06-16
    email3 prop2 2024-06-02
    email4 prop3 2024-06-25
    email1 prop2 2024-06-26
    email1 prop3 2024-06-10

    So I want to write a query that will return the emails in June but exist more than 3 times.

    SELECT * FROM `myTable`
    WHERE
    (
    (`last_sent_date` BETWEEN '2024-06-01' AND '2024-06-30')
    AND
    (//...SOME PROPERTY COUNT HERE)
    )


    The results should look like this:

    EMAIL PROPERTY LAST_SENT_DATE
    email1 prop1 2024-06-25
    email1 prop2 2024-06-26
    email1 prop3 2024-06-10

    I'm guessing it needs to do some kind of COUNT on PROPERTY, but I'm not sure where or how to add it.

    Continue reading...

Compartilhe esta Página