There's probably several ways - not saying this is best/optimal.
SELECT
categoryid, magazineid
FROM
magazinecategory a
WHERE (
SELECT
COUNT(*)
FROM
magazinecategory
WHERE
categoryid = a.categoryid
AND
magazineid <= a.magazineid
) < 3
order by categoryid, magazineid;
2011/1/11 Peter Steinheuser
> Well, if yoi have PG 8.4 and above -
>
> select categoryid, magazineid from (
> select row_number() over (partition by categoryid order by
> categoryid,magazineid asc) as row_number,
> categoryid, magazineid from magazinecategory) foo
> where row_number < 3;
> cat
On Wed, Jan 19, 2011 at 08:17:50AM -0500, Stephen Belcher wrote:
> Another way to match multiple occurrences is to use curly brackets with a
> number, like:
> select 'ab' ~ '^[a-z]{2}$';
>
> It can be done with a range of numbers as well:
> select 'ab' ~ '^[a-z]{2,4}$';
> select 'abab' ~ '^[a-z]{2
Another way to match multiple occurrences is to use curly brackets with a
number, like:
select 'ab' ~ '^[a-z]{2}$';
It can be done with a range of numbers as well:
select 'ab' ~ '^[a-z]{2,4}$';
select 'abab' ~ '^[a-z]{2,4}$';
I believe, however, that the curly brackets notation was introduced in
I'd think you need to indicate multiple alphabetic matches. Your first
regex actually matches only b followed by end of string and the second is
really only matching start of string followed by a. The third is looking
for a single character string.
Try this: select 'ab' ~ '^[a-z]+$'
or this: sel