Re: [SQL] 7.2 date/time format function problems

2002-10-23 Thread Ian Harding
Oooh. Looks like TIMESTAMP became a reserved keyword. http://archives.postgresql.org/pgsql-patches/2001-11/msg00038.php >>> Nicholas Barthelemy <[EMAIL PROTECTED]> 10/22/02 08:39AM >>> I have just installed redhat 8.0. It comes with postgresql rpms for 7.2.2. I have been trying to get an applic

[SQL] Finding table constraints

2002-10-23 Thread Jadcharla Srinivas
Hi  , I have a small doubt , if any one knows how to know Constraints of a table in Oracle9i , won't you please tell me  Warm Regards Jadcharla SrinivasViipurinkatu 1C 86,00510 HELSINKI,FINLAND.Phone:358408208487(Moblie)Do you Yahoo!? Y! Web Hosting - Let the expert host your web site

[SQL] 7.2 time format funtion issue

2002-10-23 Thread Nicholas Barthelemy
I have just installed redhat 8.0. It comes with postgresql rpms for 7.2.2. I have been trying to get an application I have written to work, but my queries fail whenever I have queries that use internal date/time formatting functions. example: SELECT a.assignmentid AS "id", u.lastname || ', ' ||

[SQL] Joining tables from different relational databases with AlligatorDBC

2002-10-23 Thread www.alligatorsql.com
Hello everybody, with AlligatorDBC (database connectivity) you are able to join table from different relational databases f.e. a table in MySQL mytab and a table in Oracle oratab This works for Oracle8i, MySQL, Interbase, Birdstep RDM, PostgreSQL and MSSQL. Select * from oratab, mytab where orat

[SQL] Multiple Databases

2002-10-23 Thread peter
Is it possible to create a view using tables from two different postgresql servers? Thanks Peter ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Stephan Szabo
On Wed, 23 Oct 2002, Tomasz Myrta wrote: > Hi > I want to perform query looking like this: > > select > user_id, > a/sum_a as percent_a, > b/sum_b as percent_b > from > users join > (select > group_id, > sum(a) as sum_a, > sum(b) as sum_b >from users group by group_id) X

Re: [SQL] 7.2 time format funtion issue

2002-10-23 Thread Tomasz Myrta
extract(DOW FROM TIMESTAMP TIMESTAMP(a.startdate)) AS "dow", ERROR: parser: parse error at or near "TIMESTAMP" Try one of these: extract(dow from cast(a.startdate as timestamp)) as "dow" extract(dow from a.startdate) as "dow" extract(dow from a.startdate::timestamp) as "dow" I remember I had pro

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Tomasz Myrta
Uz.ytkownik Stephan Szabo napisa?: Does using X.group_id=3 in the where clause work better? It works better, but not if you want to create a view and make "select * from some_view where group_id=3" :-( On 7.3 with no statistics for the table, that appears to move the filter into the subquery pl

[SQL] problem with a query

2002-10-23 Thread Carlos Sousa
hi to all i need to do a query to a small postgres database my best efort to the pretended query is in the attached file 'query.txt' but i need that some rows don't be selected of thouse that the query returns. i send in another attached file 'result.txt' with the query result. looking at conte

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Stephan Szabo
On Wed, 23 Oct 2002, Tomasz Myrta wrote: > Uz.ytkownik Stephan Szabo napisa?: > > Does using X.group_id=3 in the where clause work better? > It works better, but not if you want to create a view and make > "select * from some_view where group_id=3" :-( But you can't do that anyway, because you do

Re: [SQL] problem with a query

2002-10-23 Thread Tomasz Myrta
Użytkownik Carlos Sousa napisał: hi to all i need to do a query to a small postgres database my best efort to the pretended query is in the attached file 'query.txt' but i need that some rows don't be selected of thouse that the query returns. i send in another attached file 'result.txt' with t

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Tomasz Myrta
Uz.ytkownik Stephan Szabo napisa?: But you can't do that anyway, because you don't expose group_id in the original query. I assume user_id was a mistake then and was meant to be group_id or that both were meant to be in the select list. Yes, I meant group_id, but in orginal query I didn't have t

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Stephan Szabo
On Wed, 23 Oct 2002, Tomasz Myrta wrote: > Uz.ytkownik Stephan Szabo napisa?: > > But you can't do that anyway, because you don't expose group_id > > in the original query. I assume user_id was a mistake then and was > > meant to be group_id or that both were meant to be in the > > select list. >

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Stephan Szabo
On Wed, 23 Oct 2002, Stephan Szabo wrote: > Did you see the other two queries I gave? On 7.3, both of those queries > appear (according to explain output) to do the limiting of group_id > inside the subquery rather than doing the subquery with all rows. > The explanation above was why I believe

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Stephan Szabo
On Wed, 23 Oct 2002, Tomasz Myrta wrote: > > On Wed, 23 Oct 2002, Tomasz Myrta wrote: > > > > > Uz.ytkownik Stephan Szabo napisa?: > > Without group_id in the select list you couldn't do a where > > group_id = if the select was a view. > I know - it was just example of query. > > > Did you see t

Re: [SQL] Multiple Databases

2002-10-23 Thread Josh Berkus
Peter, > Is it possible to create a view using tables from two different > postgresql > servers? No. -Josh Berkus ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] Multiple Databases

2002-10-23 Thread Joe Conway
Josh Berkus wrote: Is it possible to create a view using tables from two different postgresql servers? No. It isn't possible with plain old SQL, but it is possible (albeit ugly) using contrib/dblink in PostgreSQL 7.2.x. See README.dblink for documentation and examples. In PostgreSQL 7.3 (i

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Tomasz Myrta
> On Wed, 23 Oct 2002, Tomasz Myrta wrote: > > > Uz.ytkownik Stephan Szabo napisa?: > Without group_id in the select list you couldn't do a where > group_id = if the select was a view. I know - it was just example of query. > Did you see the other two queries I gave? On 7.3, both of those queri

[SQL] odbc drivers

2002-10-23 Thread andres javier garcia garcia
Hi; I've got PostgreSQL 7.2 and I would like to use MSAccess2k as a front end; in a LAN, because some of my colleagues just use Windows. Where could I find a ODBC driver for Postgresql to be use under windows2000? thanks and regards -- Javier ---(end of broadca

[SQL] plpgsql cursors : dynamic or static?

2002-10-23 Thread Ludwig Lim
Hi: Are cursors in plpgsql dynamic or static? For example : ... /* some code */ FOR rec in SELECT f1,f2 FROM table1 WHERE LOOP /* some codes that manipulate table1 */ END LOOP; Do the result set pointed to by the cursor remains the same even if performed

Re: [SQL] odbc drivers

2002-10-23 Thread jasiek
> Hi; > I've got PostgreSQL 7.2 and I would like to use MSAccess2k as a > front end; in a LAN, because some of my colleagues just use Windows. > Where could I find a ODBC driver for Postgresql to be use under windows2000? > > thanks and regards What about http://odbc.postgresql.org ? Isn't it e

Re: [SQL] odbc drivers

2002-10-23 Thread Tomasz Myrta
> Hi; > I've got PostgreSQL 7.2 and I would like to use MSAccess2k as a > front end; in a LAN, because some of my colleagues just use Windows. > Where could I find a ODBC driver for Postgresql to be use under windows2000? What about http://odbc.postgresql.org ? Isn't it enough? -- Tomasz Myrta

[SQL] Hairy question - transpose columns

2002-10-23 Thread andres javier garcia garcia
Hello; I've got pluviometric data in a bizarre format (spanish administration is rather original) and I need to "transpose" them, to be able to use them as time series data for a model. The original data are in a format like cod_var | Year | Month | Ten | RainDay1 | RainDay2 | RainDay3 |

Re: [SQL] Hairy question - transpose columns

2002-10-23 Thread Stephan Szabo
On Wed, 23 Oct 2002, andres javier garcia garcia wrote: > Hello; I've got pluviometric data in a bizarre format (spanish > administration is rather original) and I need to "transpose" them, to > be able to use them as time series data for a model. > As you may see, the date of a rain datum is def

Re: [SQL] Hairy question - transpose columns

2002-10-23 Thread eric soroos
> I'm sure there's a better way, but I think a series of union alls would > do it but be rather computationally expensive. > > select cod_var, Year, Month, 1 as Day, RainDay1 as Rain > where Ten=1 > union all > select cod_var, Year, Month, 2 as Day, RainDay2 as Rain > where Ten=1 You could do t

Re: [SQL] plpgsql cursors : dynamic or static?

2002-10-23 Thread Josh Berkus
Ludwig, > Are cursors in plpgsql dynamic or static? > > For example : > > ... /* some code */ > FOR rec in SELECT f1,f2 >FROM table1 WHERE LOOP > > /* some codes that manipulate table1 */ > END LOOP; Technically speaking, that is not a cursor, even though

Re: [SQL] plpgsql cursors : dynamic or static?

2002-10-23 Thread Tom Lane
Josh Berkus <[EMAIL PROTECTED]> writes: >> Are cursors in plpgsql dynamic or static? >> >> FOR rec in SELECT f1,f2 >> FROM table1 WHERE LOOP >> >> /* some codes that manipulate table1 */ >> END LOOP; > Technically speaking, that is not a cursor, even though it serves the same > purpose.

[SQL] Sum of Every Column

2002-10-23 Thread Tom Haddon
Hi Folks, I'm hoping to put together a query that generates a report on a table with a large number of boolean fields. This report has to be able to adapt to the number of fields in the table. Essentially, I want it to provide the sum of TRUE values for each field for a given subset of the table.

[SQL] Sum of Every Column

2002-10-23 Thread Tom Haddon
Hi Folks, I'm hoping to put together a query that generates a report on a table with a large number of boolean fields. This report has to be able to adapt to the number of fields in the table. Essentially, I want it to provide the sum of TRUE values for each field for a given subset of the table.

Re: [SQL] Sum of Every Column

2002-10-23 Thread Jean-Luc Lachance
Tom, You can add sum( case when then 1 else 0 end) for each field that you need. JLL Tom Haddon wrote: > > Hi Folks, > > I'm hoping to put together a query that generates a report on a table with > a large number of boolean fields. This report has to be able to adapt to > the number of fie

Re: [SQL] Sum of Every Column

2002-10-23 Thread Josh Berkus
Tom, > I'm hoping to put together a query that generates a report on a table with > a large number of boolean fields. This report has to be able to adapt to > the number of fields in the table. Essentially, I want it to provide the > sum of TRUE values for each field for a given subset of the tab

[SQL] sub-select trouble: wrong SQL or PostgreSQL issue?

2002-10-23 Thread patrick
Greetings, I have 3 tables. Two of which (ta and tb) are different "attributes" the third table (tc) can have. tc is allowed up to three of each kind of "attributes". e.g., 3 ta values and 2 tb values. By assigning ta and tb attributes to each entry in tc you are also "matching" tb attributes

Re: [SQL] sub-select trouble: wrong SQL or PostgreSQL issue?

2002-10-23 Thread Stephan Szabo
> Strangely, this is the result we were expecting from our > original query! > > Is it possible that the sub-selects are somehow > affecting the result sets? > > > Seen on: > % postmaster --version > postmaster (PostgreSQL) 7.1.3 > > and > > % postmaster --version > postmaster (PostgreSQL) 7.1.2

Re: [SQL] sub-select trouble: wrong SQL or PostgreSQL issue?

2002-10-23 Thread Tom Lane
>> Is it possible that the sub-selects are somehow >> affecting the result sets? > I think you want to upgrade, 7.3beta at least gives your > expected output on all the queries when I tried it. I don't > currently have a 7.2.* system to test on here to try it > with that series. I think this may

[SQL] Simulating a SELECT..FOR UPDATE to LOCK and SELECT statement

2002-10-23 Thread Ludwig Lim
Hi: Is there a way to emulate a SELECT..FOR UPDATE to series of LOCK/SELECT statement. I tried the following statements using 2 psql terminals. T1 | T2 1)BEGIN; | 2)SELECT x | BEGIN; FROM y | WHERE y=1

[SQL] sub-select with aggregate

2002-10-23 Thread Tomasz Myrta
Hi I want to perform query looking like this: select user_id, a/sum_a as percent_a, b/sum_b as percent_b from users join (select group_id, sum(a) as sum_a, sum(b) as sum_b from users group by group_id) X using (group_id) where group_id=3; This query works, but very slow. Subquery

Re: [SQL] sub-select with aggregate

2002-10-23 Thread Tomasz Myrta
> The other forms only move the filtering clauses around. There's > still only a filter on the outer group_id equaling the inner > group_id and a filter on group_id=3. It's just a question of > whether it's: > > Scan users in subselect from group_id=3, group and aggregate them > and join wit