Re: [SQL] Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?

2007-06-29 Thread Oleg Bartunov

On Thu, 28 Jun 2007, Andreas Joseph Krogh wrote:


Anybody knows if queries of type "LIKE '%234%'" ever will be able to use
indexes, and if someone is working on it? I'm sure I'm not the only one who
would very much appreciate it:-)



This is quite easily could be done with tsearch using substring dictionary.
Search archives !

Regards,
Oleg
_
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru),
Sternberg Astronomical Institute, Moscow University, Russia
Internet: [EMAIL PROTECTED], http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83

---(end of broadcast)---
TIP 6: explain analyze is your friend


[SQL] percentages of a column

2007-06-29 Thread Andreas

Hi,

There is a Select that calculates some SUMs of objects.
I'd like to show a list of counts and percentages of this counts based 
on the sum of all counts.

Is that possible in a SELECT statement?

Example:  


Fruit  Count   %
--
Bananas   5  10%
Apples   15  30%
Oranges 30  60%



---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [SQL] percentages of a column

2007-06-29 Thread Gregory Stark
"Andreas" <[EMAIL PROTECTED]> writes:

> Example:
>
> Fruit  Count   %
> --
> Bananas   5  10%
> Apples   15  30%
> Oranges 30  60%

select fruit_name, count(*), 
   round(count(*)::numeric / (select count(*) from basket) * 100, 
0)::text||'%' as "%"
  from basket 
 group by fruit_name
 order by "%";

 fruit_name | count |  %  
+---+-
 Bananas| 5 | 10%
 Apples |15 | 30%
 Oranges|30 | 60%
(3 rows)

-- 
  Gregory Stark
  EnterpriseDB  http://www.enterprisedb.com


---(end of broadcast)---
TIP 6: explain analyze is your friend