Re: [SQL] to_char() and order-by

2002-06-28 Thread Karel Zak

On Thu, Jun 27, 2002 at 12:27:11PM -0700, Jeff Boes wrote:
> Perhaps this was covered in the 7.2.x release notes, but it's mystifying us:

 Please, how are data without to_char()? 
 
 select time_link from stat_fetch 
 where time_link is not null 
 order by 1 desc limit 10;

Karel

> select to_char(time_link,'999.99') from stat_fetch
> where time_link is not null
> order by 1 desc limit 10;
> 
> (time_link is a double-precision column.)  Under 7.1.3, this returns results like:
> 
>  to_char 
> -
> 9.99
> 9.99
> 9.99
> 9.99
> 9.99
> 9.99
> 9.99
> 9.99
> 9.99
> 9.99
> (10 rows)
> 
> while under 7.2.1, you get the top 10 rows in *numerical* order:
> 
>  to_char 
> -
>   278.78
>   261.07
>   240.25
>   180.24
>   173.26
>   160.35
>   159.02
>   144.57
>   134.21
>   131.66
> (10 rows)

-- 
 Karel Zak  <[EMAIL PROTECTED]>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html





[SQL] creating functional index over multiple columns

2002-06-28 Thread Chantal Ackermann

hello all,

I am new to this list, and I hope my request is well placed, here. I 
tried searching the archives but I wasn't lucky.

I want to create an index over two columns and one function:

the WHERE clause is:
WHERE lower(name)=? AND type_id=? AND syn_id=?

I know from the docs that I have to create on function that wraps these 
three values for creating the appropriate index. I have practically no 
idea how to do this (e.g. what type/set should this function return?).

Thanks a lot for pointers to documentation/former postings or any help
Cheers
Chantal




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