Q&A for Ubuntu users and developers
WITH predvyber AS ( SELECT -- TOP(10) Users.Id, Users.DisplayName, Posts.Title, Posts.CreationDate, Posts.ViewCount FROM Posts JOIN Users ON Posts.OwnerUserId = Users.Id WHERE Posts.PostTypeId = 1 AND Posts.CreationDate > '2023-11-01' AND Posts.ViewCount > 1 AND (Users.Id = 4710409 OR Users.Id = 476371) -- ORDER BY -- Users.Id, -- Posts.ViewCount DESC -- OFFSET 0 ROWS ) SELECT predvyber.* FROM predvyber WHERE (SELECT COUNT(*) FROM predvyber AS pocitadlo WHERE pocitadlo.Id = predvyber.Id ) < 4 ORDER BY predvyber.Id, predvyber.ViewCount DESC;