Re: [SQL] Question about slow Select when using 'IN'.

2002-12-02 Thread Tom Lane
Mike Winter writes: > My query is of the form: > SELECT col, count(col) FROM tab WHERE id IN (3, > 4,7,2, ...) GROUP BY COL ORDER BY count > for a very large number of rows. > I have an index on id, so the explain looks like: > Aggregate (cost=12.12..12.14 rows=1 width=5) > -> Group (cost=1

Re: [SQL] CURRENT_TIMSTAMP

2002-12-02 Thread Stephan Szabo
On Mon, 2 Dec 2002, Raymond Chui wrote: > I created a column, dada type timstamp with time zone > and with default CURRENT_TIMSTAMP > it shows me the default is > > default ('now'::text)::timstamp(6) with time zone > > Then when I insert a row, the default timestamp value is > > -mm-dd HH:MM:s

Re: [SQL] Min and Max

2002-12-02 Thread Jean-Luc Lachance
If you do not mind non standard, how about: SELECT DISTINCT ON(id_father) * FROM children ORDER BY id_father, child_age; Dennis Björklund wrote: > > On 29 Nov 2002, Sergio Oshiro wrote: > > > How can I get the rows of the children name and its "father" such that > > they have the min child_age

Re: [SQL] Combining queries while preserving order in SQL - Help!

2002-12-02 Thread Joel Burton
On Mon, Dec 02, 2002 at 01:46:38PM -0500, Casey Allen Shobe wrote: > Hi there, > > I need to do the following in one SQL query: > > select field1, field2, field3, field4, field5 from table where field6 < 5 > order by field1 > > And a totals line which shows the sum for each column. > > The impo

Re: [SQL] Accumulative Queries?

2002-12-02 Thread Joel Burton
On Sat, Nov 30, 2002 at 02:40:08PM -0800, Benjamin Smith wrote: > Let's say you have a table of Financial transactions: > > Create table checks ( > id serial, > number varchar, > to varchar, > amount real, > date integer > ); > > (date is an epoch timestamp) > > And you want to get a li

[SQL] Combining queries while preserving order in SQL - Help!

2002-12-02 Thread Casey Allen Shobe
Hi there, I need to do the following in one SQL query: select field1, field2, field3, field4, field5 from table where field6 < 5 order by field1 And a totals line which shows the sum for each column. The important part is that I need to preserve the order by of the first query. Is there any wa

Re: [SQL] Min and Max

2002-12-02 Thread Joel Burton
On Fri, Nov 29, 2002 at 10:55:54AM -0800, Sergio Oshiro wrote: > Hello, everybody! > > I've trouble to make a "simple"(?) query... > > The following table is an example: > > table: children > id_father | child_name | child_age > --++ > 1 | John | 2 >

Re: [SQL] Min and Max

2002-12-02 Thread Dennis Björklund
On 29 Nov 2002, Sergio Oshiro wrote: > How can I get the rows of the children name and its "father" such that > they have the min child_ages? > > -- the following does not return the child_name... > select id_father, min(child_age) from children group by id_father; > select id_father, max(child_a

Re: [SQL] CURRENT_TIMSTAMP

2002-12-02 Thread Joel Burton
On Mon, Dec 02, 2002 at 11:41:33AM -0500, Raymond Chui wrote: > I created a column, dada type timstamp with time zone > and with default CURRENT_TIMSTAMP > it shows me the default is > > default ('now'::text)::timstamp(6) with time zone > > Then when I insert a row, the default timestamp value is

[SQL] Min and Max

2002-12-02 Thread Sergio Oshiro
Hello, everybody! I've trouble to make a "simple"(?) query... The following table is an example: table: children id_father | child_name | child_age --++ 1 | John | 2 1 | Joe| 3 1 | Mary | 4 1 | Cristine | 4

[SQL] CURRENT_TIMSTAMP

2002-12-02 Thread Raymond Chui
I created a column, dada type timstamp with time zone and with default CURRENT_TIMSTAMP it shows me the default is default ('now'::text)::timstamp(6) with time zone Then when I insert a row, the default timestamp value is -mm-dd HH:MM:ss.m+00 where m is milliseconds. How do I make d

[SQL] SQL99

2002-12-02 Thread Evgen Potemkin
Hi there! Can anybody explain behavior of ? Or give a link where explanation can be found? Or something like that ?:) To my regret, i can't figure it out right from SQL standard description with my "brute force". regards, --- .evgen ---(end of broadcast)---

[SQL] Accumulative Queries?

2002-12-02 Thread Benjamin Smith
Let's say you have a table of Financial transactions: Create table checks ( id serial, number varchar, to varchar, amount real, date integer ); (date is an epoch timestamp) And you want to get a listing of checks "SELECT * FROM checks ORDER BY date ASC"; but you also want to have an

[SQL] Need Postgresql Help

2002-12-02 Thread Atul Pedgaonkar
Respected sir, Atul Pedgaonkar here from india. I am using postgresql7.2 as backend and for front-end ,perl5.6.1. I need some help regarding postgresql stored procedure. The problem is like this 1)How to create stored procedure in postgresql ? 2)How can i use it from

[SQL] Question about slow Select when using 'IN'.

2002-12-02 Thread Mike Winter
Hi all, I hope someone can help me out. I'm doing single-table select statements on a large table and I could use some help in speeding it up. My query is of the form: SELECT col, count(col) FROM tab WHERE id IN (3, 4,7,2, ...) GROUP BY COL ORDER BY count for a very large number of rows. I have

Re: [SQL] Need Postgresql Help

2002-12-02 Thread Richard Huxton
On Monday 02 Dec 2002 8:42 am, Andreas Joseph Krogh wrote: > On Monday 02 December 2002 09:44, Atul wrote: > > Respected sir, > > Atul Pedgaonkar here from India. I am using postgresql7.2 as > > backend and for front-end, perl5.6.1. I need some help regarding > > postgresql-stored proc

Re: [SQL] Need Postgresql Help

2002-12-02 Thread Andreas Joseph Krogh
On Monday 02 December 2002 09:44, Atul wrote: > Respected sir, > Atul Pedgaonkar here from India. I am using postgresql7.2 as > backend and for front-end, perl5.6.1. I need some help regarding > postgresql-stored procedure. The problem is like this > > 1)How to create stored pr

[SQL] Need Postgresql Help

2002-12-02 Thread Atul
Respected sir, Atul Pedgaonkar here from India. I am using postgresql7.2 as backend and for front-end, perl5.6.1. I need some help regarding postgresql-stored procedure. The problem is like this     1)How to create stored procedure in postgresql?     2)How can i use