MySQL Forums
Forum List  »  Newbie

Temporary Table with having count
Posted by: F K
Date: October 31, 2024 08:57AM

Hello everyone,

I hope you can help me.

I have a table with measurement data. Each measurement has its own ID and dozens of measurements are taken every day.

I have used HAVING COUNT to display which days have at least 600 measurements, because I only need these days.

The syntax for this is as follows:

select
count(id) as TotalIdPerDay,
gmtdate as Date
from
table
group by
date
having
count(*) > 600
order by
count(id) desc

Now I want to transfer these results to a temporary table.

Can this be done with a single query?

I did it manually, which is very time-consuming (the date is always a day that has more than 600 measurements:

create temporary table
temp_table
select
*
from
data
where
Date = '2024-10-13'
or
Date = '2024-10-23'
or
Date = '2024-10-01'
or
Date = '2024-10-06'
or
Date = '2024-10-20'
or
Date = '2024-10-21'
or
Date = '2024-10-02'
or
Date = '2024-10-11'
or
Date = '2024-10-15'
or
Date = '2024-10-25'
or
Date = '2024-10-08'
or
Date = '2024-10-09'
or
Date = '2024-10-03'
or
Date = '2024-10-07'
or
Date = '2024-10-04'
or
Date = '2024-10-27'
or
Date = '2024-09-30'
;

I would like this to be easier so that I don't forget anything.

So every day that has at least 600 measurements should be recorded and the data transferred to the temporary table.

Many thanks for your ideas and best regards

Options: ReplyQuote


Subject
Written By
Posted
Temporary Table with having count
F K
October 31, 2024 08:57AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.