SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table sales ( dt date not null, inn int not null, REV money not null ) go insert into sales (dt, inn, REV) values ('20220101', 1, 9226), ('20220201', 1, 10166), ('20220301', 1, 10916), ('20220401', 1, 8824), ('20220501', 1, 7449), ('20220601', 1, 6243), ('20220701', 1, 7403), ('20220801', 1, 7145), ('20220901', 1, 6948), ('20221001', 1, 7634) go select inn from sales where REV < 10000 group by inn having count(dt) = 10 go select inn from sales --where REV < 10000 group by inn having count(dt) = 10 go select inn from sales group by inn having count(rev) = count(case when rev < 10000 then 1 end) go With a as (select dt, inn, sum(rev),max (rev) over ( partition by inn) as max_rev from sales Group by dt, inn) Select a.* from a where max_rev<10000 Go
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear