Re: [SQL] Cross tabulations

2004-10-19 Thread Greg Stark
"Muhyiddin A.M Hayat" <[EMAIL PROTECTED]> writes: > Dear all, > > I need to do something similar to a cross tabulation, but without any > aggregation. join your table to itself four times: select * from (select check_time::date as date, employee_id, check_time-check_time::date as in from te

[SQL] Cross tabulations

2004-10-19 Thread Muhyiddin A.M Hayat
Dear all,I need to do something similar to a cross tabulation, but without anyaggregation.I have below table id | employee_id |   state   | check_time+-+---+ 21 |   1 | In    | 2004-10-12 21:37:13 22 |   1 | Break Out |

Re: [SQL] help with to_date and to_char

2004-10-19 Thread Thomas F.O'Connell
Yup, even better. For some reason I gave up trying to_date( '02', 'MON' ), which clearly wasn't working. Thanks for the improvement! -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260

[SQL] Which type of functions are best?

2004-10-19 Thread Postgres User
Hi, I'm just starting out and am looking to speed up queries using either SQL functions or PLPGSQL functions. I have googled around and have not found a great answer saying that this is the way to go. I would like to use PREPARE/EXECUTE... but of course they only last for each connection, I w

Re: [SQL] need query advice

2004-10-19 Thread Pierre-Frédéric Caillaud
argh, you could use contribs/intarray with a gist index... instead of N columns use an integer[] and gist-index it, then write the equivalent of : where (intersection of the search array with the data array) has at least 5 elements (or 4 elements) (or at least 4 elements order by

Re: [SQL] help with to_date and to_char

2004-10-19 Thread Edmund Bacon
Edmund Bacon wrote: When current_date is, say Aug 31 then select to_char( to_date('05' || '/' || to_char(current_date, 'DD/'), 'MM/DD/' ), 'MON' ); NUTS! that should have been select ... to_date('02' || ... { cut, paste, ?edit? } returns 'MAR', which is probably not what

Re: [SQL] help with to_date and to_char

2004-10-19 Thread lorid
Thanks Thomas it worked great ,even when I put in the var - when_month :) Lori Thomas F.O'Connell wrote: There might be a better way, but this should do what you want. And I think that you can safely replace '05' with when_month. select to_char( to_date( '05' || '/' || to_char( current_date, 'DD

Re: [SQL] help with to_date and to_char

2004-10-19 Thread Edmund Bacon
Thomas F.O'Connell wrote: There might be a better way, but this should do what you want. And I think that you can safely replace '05' with when_month. select to_char( to_date( '05' || '/' || to_char( current_date, 'DD/' ), 'MM/DD/' ), 'MON' ); Perhaps select to_char(to_date('02', 'MM')

Re: [SQL] the problem of createlang!

2004-10-19 Thread Tom Lane
"Fang Genjie" <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] postgresql-7.4.5]$ createlang plpgsql BBMF > ERROR: Load of file /usr/local/pgsql/lib/plpgsql.so failed: > /usr/local/pgsql/lib/plpgsql.so: undefined symbol: error_context_stack Looks like you are trying to load a 7.4 plpgsql.so into

Re: [SQL] help with to_date and to_char

2004-10-19 Thread Thomas F.O'Connell
There might be a better way, but this should do what you want. And I think that you can safely replace '05' with when_month. select to_char( to_date( '05' || '/' || to_char( current_date, 'DD/' ), 'MM/DD/' ), 'MON' ); -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitenin

Re: [SQL] libpq-fe: PQgetvalue() ?

2004-10-19 Thread ljb
[EMAIL PROTECTED] wrote: > hi > > does PQgetvalue() allocate memory rof its result, it returns ? > the answer will help me in problem: > should i free some cstring_variable if > { cstring_variable=PQgetvalue(pgresult_variable,0,0); } > and could i PQclear(pgresult_varible) while cstring_varible is

[SQL] need query advice

2004-10-19 Thread Stephan Fiebrandt
Hello all, i've got a psql database, with a table including 6 rows named "zahl1 zahl2 zahl3 zahl4 zahl5 and zahl6" type integer There are about 10.000 entries in the table. In every entry, the numbers are uniq to each other. That means, if zahl1=1, then zahl2-6 cannot be also 1. Example: 1, 1

[SQL] the problem of createlang!

2004-10-19 Thread Fang Genjie
I have installed postgresql (version 7.4.5) on the Redhat linux platform. Now I want to create a database with name BBMF and create pl/pgsql procedure language to the BBMF The problem is listed follow:   [EMAIL PROTECTED] postgresql-7.4.5]$ psql -l     List of databases  Database 

[SQL] help with to_date and to_char

2004-10-19 Thread Lori
Im trying to do something very simple I have a field called when_month (integer ) so I want to get the month name for the integer this comes close to what I want update mytable set myfield=to_char(current_timestamp,'MON'); the result is myfield is set to OCT which is close to what I want but when I

Re: [SQL] Aggregate Function with Argument

2004-10-19 Thread Mark Gibson
David Siegal wrote: I would like to create an aggregate function that returns a concatenation of grouped values. It would be particularly useful if I could pass an optional delimiter into the aggregate function. I've managed to do this in two stages: 1. Collect the set of values into an array. T

Re: [SQL] bibliographic schema

2004-10-19 Thread Guillaume
Karsten Hilbert wrote: we're looking for a SQL database schema for bibliographical references. the goal is to extract all the bibliographical references contained in our various existing pgsql scientific databases in only one specific database and to interconnect them with external keys and perl sc

Re: [SQL] problems using phpPgAmin

2004-10-19 Thread Mark Gibson
beyaNet wrote: Hi, to those of you that may be using the above named admin tool, any ideas why I am unable to login with the postgres username even though I have amended the pg_hb file? Are there any other admin tools out there that i could use on a a unix box? Have you restarted PostgreSQL? Hav

Re: [SQL] Ordering a record returned from a stored procedure - date

2004-10-19 Thread Richard Huxton
Kent Anderson wrote: Never mind, it requires on each side of the variable. You will be delighted to learn that "dollar quoting" is in 8.0, which allows you to do things like: CREATE FUNCTION AS $$ ...function body here without needing doubling of ' $$ LANGUAGE plpgsql; I believe

Re: [SQL] bibliographic schema

2004-10-19 Thread Karsten Hilbert
> > we're looking for a SQL database schema for bibliographical references. > > the goal is to extract all the bibliographical references contained in > > our various existing pgsql scientific databases in only one specific > > database and to interconnect them with external keys and perl scripts.