Thread: Greater than a value

Greater than a value

From
"Fontenot, Paul"
Date:
I have the following query:

select count(*),msg_text from msg_table where msg_text like '%PIX-1%'
group by msg_text order by count desc;

And I qould like to be able to do something like:

select count(*),msg_text from msg_table where msg_text like '%PIX-1%'
COUNT => '50' group by msg_text order by count desc;

Is that possible in PostgreSQL?

 ***PRIVILEGED & CONFIDENTIAL***
Unless expressly stated otherwise, this message (and any attachment(s)
thereto) is confidential and may be privileged. It is intended for the
addressee(s) only. If you are not an addressee, any disclosure or
copying of the contents of this e-mail or any action taken (or not
taken) in reliance on it is strictly prohibited. If you are not an
addressee, please inform sender immediately and delete this message from
your system.

Re: Greater than a value

From
Josh Berkus
Date:
Paul,

> select count(*),msg_text from msg_table where msg_text like '%PIX-1%'
> COUNT => '50' group by msg_text order by count desc;
>
> Is that possible in PostgreSQL?

Yes.  You need an "intro to SQL" book to help you with this sort of thing;
consider "SQL Queries for Mere Mortals".

SELECT count(*) as no_msg, msg_text FROM msg_table
WHERE msg_text LIKE '%PIX-1%'
GROUP BY msg_text
HAVING count(*) >= 50
ORDER BY no_msg DESC;


--
-Josh Berkus
 Aglio Database Solutions
 San Francisco