Re: [SQL] query doesn't always follow 'correct' path..

2013-02-18 Thread Frank Lanitz
Am 18.02.2013 10:43, schrieb Bert: > Does anyone has an idea what triggers this bad plan, and how I can fix it? Looks a bit like wrong statistics. Are the statistiks for your tables correct? Cheers, Frank -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to y

Re: [SQL] Setting the process title, or can I?

2012-03-20 Thread Frank Bax
On 03/20/12 06:14, Bèrto ëd Sèra wrote: So as a dirty and quick hack to make sure our failure filter works I wanted to have an external process kill and relaunch the filter from cron each 30 minutes. Is there anyway I can mark the process running the filter, maybe using the update_process_title

Re: [SQL] No sort with except

2012-03-01 Thread Frank Lanitz
R BY pernr, eindt DESC; > --- > > In this case the ORDER BY does not work: I will get the same person > data, either with DESC as with ASC, even when this should change. > > Does anyone have an explanation for this? Don't you sort just the part at EXCEPT? Cheers, Frank -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Clever way to check overlapping time intervals ?

2011-09-16 Thread Frank Bax
On 09/15/11 19:40, Andreas wrote: Hi, is there a clever way to check overlapping time intervals ? An option named n should be taken from date y to y. The same name is ok for another interval. e.g. table : mytab ( d1 date, d2 date, n text, v text ) There should be a constraint to provide no row

Re: [SQL] counting related rows

2010-10-08 Thread Frank Bax
James Cloos wrote: I have a table which includes a text column containing posix-style paths. Ie, matching the regexp "^[^/]+(/[^/]+)*$". I need to do a query of a number of columns from that table, plus the count of rows which are "children" of the current row. The query: SELECT count(*) AS

[SQL] join returns too many results...

2010-10-03 Thread Frank Bax
When I join tables; I will sometimes get multiple rows back as in this example. create table class(name varchar, p point, d int); insert into class values( 'All', point(50,50), 100 ); insert into class values( 'NE70', point(70,70), 20 ); insert into class values( 'NE75', point(75,75), 20 ); inse

Re: [SQL] Question regarding indices

2010-09-14 Thread Frank Bax
Steve wrote: Original-Nachricht Datum: Sat, 11 Sep 2010 11:08:00 -0400 Von: Lew An: pgsql-sql@postgresql.org Betreff: Re: [SQL] Question regarding indices On 09/11/2010 08:29 AM, Steve wrote: I have a small question about the order of values in a query. Assume I have a tab

Re: [SQL] What does PostgreSQL do when time goes backward?

2010-08-04 Thread Frank Bax
John Hasler wrote: Frank writes: My ntp client changes clock (by small amount) at any time: Jul 25 05:29:38 bax ntpd[10269]: adjusting local clock by 0.098724s Jul 25 05:31:43 bax ntpd[10269]: adjusting local clock by 0.038991s Jul 25 06:13:38 bax ntpd[10269]: adjusting local clock by

Re: [SQL] What does PostgreSQL do when time goes backward?

2010-08-04 Thread Frank Bax
John Hasler wrote: How does PostgreSQL react to time being stepped at bootup? My Chrony NTP package might cause it to do so on rare occasions when the hardware clock is way off. This would only happen during bootup. My ntp client changes clock (by small amount) at any time: Jul 25 05:29:38

Re: [SQL] How do I remove selected words from text field?

2010-07-01 Thread Frank Bax
Osvaldo Kussama wrote: 2010/7/1 Frank Bax : Create some tables; then add some data: create table t1 (i int, v varchar); insert into t1 values(1,'A B C D'); insert into t1 values(2,'B D E F'); insert into t1 values(3,'G H I J'); insert into t1 values(4,'

Re: [SQL] How do I remove selected words from text field?

2010-07-01 Thread Frank Bax
Create some tables; then add some data: create table t1 (i int, v varchar); insert into t1 values(1,'A B C D'); insert into t1 values(2,'B D E F'); insert into t1 values(3,'G H I J'); insert into t1 values(4,'E'); create table t2 (q varchar, z varchar); insert into t2 values('A','vowel'); insert

Re: [SQL] How do I remove selected words from text field?

2010-06-26 Thread Frank Bax
Osvaldo Kussama wrote: 2010/6/25 Frank Bax : I'm not quite sure how to ask for the query I want, so let's start with data: create table t1 (i int, val varchar); insert into t1 values(1,'A B C D'); insert into t1 values(2,'B D E F'); insert into t1 values(3,

Re: [SQL] How do I remove selected words from text field?

2010-06-26 Thread Frank Bax
Osvaldo Kussama wrote: 2010/6/25 Frank Bax : I'm not quite sure how to ask for the query I want, so let's start with data: create table t1 (i int, val varchar); insert into t1 values(1,'A B C D'); insert into t1 values(2,'B D E F'); insert into t1 values(3,

[SQL] How do I remove selected words from text field?

2010-06-25 Thread Frank Bax
I'm not quite sure how to ask for the query I want, so let's start with data: create table t1 (i int, val varchar); insert into t1 values(1,'A B C D'); insert into t1 values(2,'B D E F'); insert into t1 values(3,'G H I J'); create table t2 (q varchar, z varchar); insert into t2 values('A','vowel

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Frank Bax
Gavin McCullagh wrote: On Thu, 17 Sep 2009, Frank Bax wrote: Gavin McCullagh wrote: SELECT time, to_timestamp(time) AS ts, EXTRACT('months',to_timestamp(time)) FROM mdl_log; ERROR: syntax error at or near "," LINE 1: ...t time, to_timestamp(time) AS ts, extract('

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Frank Bax
Gavin McCullagh wrote: SELECT time, to_timestamp(time) AS ts, EXTRACT('months',to_timestamp(time)) FROM mdl_log; ERROR: syntax error at or near "," LINE 1: ...t time, to_timestamp(time) AS ts, extract('months',to_times... Try replacing extract('month',value) with extract('months' from value

Re: [SQL] Substring

2009-09-04 Thread Frank Bax
Raj Mathur wrote: On Saturday 05 Sep 2009, bilal ghayyad wrote: I have an sql script function that take one text parameter "funct (text)", what I need to do is the following: If the parameter name is string and its value was for example "abcd" then I need to do a query based on ab and then base

Re: [SQL] how to tell if column set on update

2009-07-22 Thread Frank Bax
chester c young wrote: Le 20/07/09 15:19, chester c young a écrit : within a trigger need to know if the UPDATE statement set a column. the column might be set to the old value or a different value. (want to make sure the app is sending all necessary values) thanks If the column to test i

Re: [SQL] De-duplicating rows

2009-07-17 Thread Frank Bax
Richard Huxton wrote: Christophe wrote: Now, since this database has been production since 7.2 days, cruft has crept in: in particular, there are duplicate email addresses, some with mismatched attributes. The policy decision by the client is that the correct row is the one with the earliest

[SQL] Make the planner smarter about idiosyncratic (or broken) ORM behaviour

2009-05-22 Thread Frank Jördens
M, which is filtering Person by properties on the related user table, then it will create a join for each of those it seems. Our Django experts are telling me that it is probably not practical to fix in the ORM, as it seems to be structural (anyway not fixable for us in the near term). Hence I am wondering if anyone has an idea as to how to make the planner smarter about such weirdness (or brokenness); you might argue that the 2nd join there is merely syntactic bloat which the planner might just recognize as such? We are using: woome_video=# select version(); version - PostgreSQL 8.3.5 on x86_64-pc-linux-gnu, compiled by GCC cc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3) (1 row) Regards, Frank -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] diff b/w varchar(N) & text

2009-03-17 Thread Frank Bax
sathiya psql wrote: Is there any big difference between selecting the data type as varchar(N) and text. What is the difference of it when seeing from the performance side ? Check the manual. There is no difference! http://www.postgresql.org/docs/8.3/static/datatype-character.html -- Sent

[SQL] Partitoning not working with RETURNING and INSERT/UPDATE

2009-02-10 Thread Frank Jördens
iewer_id", "viewed_id") VALUES (94039, 60701) RETURNING id; ERROR: cannot perform INSERT RETURNING on relation "userstats_profileview" HINT: You need an unconditional ON INSERT DO INSTEAD rule with a RETURNING clause. -- snap -- Is there any way to make this work? Regards,

Re: [SQL] plpgsql setof help

2009-01-28 Thread Frank Bax
Tom Lane wrote: "Matthew T. O'Connor" writes: I want the following: select column_to_english_list( select towns from towns_table ); to return: 'town1, town2 and town3' I wonder though if it wouldn't be better to recast the problem as an aggregate: select column_to_english_list(towns) from

Re: [SQL] store pdf files

2008-12-09 Thread Frank Bax
ivan marchesini wrote: Hi to all... I need to create a db that contain link to some pdf files.. At the moment these are simple links (to the files that are stored into the file system) storing paths into a column of a dbf table... I need to manage this data considering that the db I'm going to c

Re: [SQL] [GENERAL] date range query help

2008-11-20 Thread Frank Bax
novice wrote: 2008/11/20 Rodrigo E. De León Plicet <[EMAIL PROTECTED]>: On Wed, Nov 19, 2008 at 10:03 PM, novice <[EMAIL PROTECTED]> wrote: sorry I get nothing :( Of course not. None of the dates you gave in the example overlap. But it should still have the 1st entry with the name Ben? Am

Re: [SQL] need help in building a query

2008-11-07 Thread Frank Bax
the question; but I still don't know what you want. You're initial question indicated you were trying to calculate the proper discount for each customer. This example mentions neither customers nor discounts at all and appears to be looking for a specific transaction instead. Frank

Re: [SQL] Most efficient way to achieve this ts_query

2008-10-15 Thread Frank Bax
Jamie Tufnell wrote: If someone uses a search query on my site like this: "abc def" I would like to return all results for 'abc & def' first, followed by all results for tsquery 'abc | def' is there some way to express this in one tsquery? What's the most efficient way to go about this? The s

Re: [SQL] Query how-to

2008-10-02 Thread Frank Bax
t3 on t3.stop::date=series.date::date where open is not null or closed is not null Frank -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] a simple transform

2008-09-16 Thread Frank Bax
Karl Grossner wrote: I've thrashed at this transform for quite a while and come up empty. The crosstab() functions, and the documented examples, all do something more complex than I need. I can do this after the fact trivially in python with the 'zip()' function, but I need it real-time from a vi

Re: [SQL] selecting current UTC time

2008-09-14 Thread Frank Bax
[EMAIL PROTECTED] wrote: Hi, Is it possible to select the current UTC time as type timestamp with time zone? select localtimestamp; 2008-09-14 21:55:24.367796 select localtimestamp at time zone 'UTC'; 2008-09-15 09:55:42.3478+12 (not sure if what this result is) select current_timesta

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: No looks like I have 8.2 This works on 8.2: String_to_array(regexp_replace(description,E'\\s+',' ','g'),' ') -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: Just testing the regexp_string_to_array This SQL select description, regexp_string_to_array(description::text , E'\\s+' ) as optdesc, securitytype from xx where type = 'B' order by 1 produced this error: ERROR: function regexp_string_to_array(text, text) does n

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: Noticed that string_to_array does not handle double spaces very well. If there are double space between the tokens, there is "" (empty string) in the array returned. Not exactly what I expected. Try regexp_replace http://www.postgresql.org/docs/8.3/interactive/functions-st

Re: [SQL] variables with SELECT statement

2008-09-05 Thread Frank Bax
Kevin Duffy wrote: Within my table there is a field DESCRIPTION that I would like to parse and split out into other fields. Within DESCRIPTION there are spaces that separate the data items. String_to_array(description, ‘ ‘) does the job very well. I need something like this to work.

Re: [SQL] DELETE with JOIN

2008-08-07 Thread Frank Bax
[EMAIL PROTECTED] wrote: On Thu, Aug 07, 2008 at 03:00:35PM -0400, Frank Bax wrote: If you're really desperate; is it possible to alter table 'a' to add column b_id; populate it; delete your rows without a join; then drop the column? I thought of something similar, but UPDA

Re: [SQL] DELETE with JOIN

2008-08-07 Thread Frank Bax
[EMAIL PROTECTED] wrote: On Thu, Aug 07, 2008 at 10:40:22AM -0700, Steve Midgley wrote: Have you tried something where you read in all those "IN id's" and then group them into blocks (of say 1,000 or 10,000 or whatever number works best)? Then execute: DELETE FROM a WHERE a.b_id in ([static_

Re: [SQL] Case Insensitive searches

2008-08-04 Thread Frank Bax
x27;; and I doubt that there is special code to handle case where length of argument is exactly the same as column. However; ~* '^a' which anchors search to first character is perhaps more likely to use an index scan. Frank -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] query: last N price for each product?

2008-07-04 Thread Frank Bax
David Garamond wrote: Dear SQL masters, The query for "latest price for each product" goes like this (which I can grasp quite easily): SELECT * FROM price p1 WHERE ctime=(SELECT MAX(ctime) FROM price p2 WHERE p1.product_id=p2.product_id) or: SELECT * FROM price p1 WHERE NOT EXISTS (SELECT

Re: [SQL] LEFT OUTER JOIN question

2008-05-04 Thread Frank Bax
Craig Ringer wrote: > seiliki wrote: >> I expect the SELECT to return two rows. Would some kind >> soul explain for me why it gives only one row? > > Without having read the post in detail I'll make a guess: Because NULL = > NULL results in NULL, not true, and the outer (or any other) join > cond

Re: [SQL] First day of month, last day of month

2008-04-24 Thread Frank Bax
Frank Bax wrote: Nacef LABIDI wrote: is there a better method to retrieve all the rows with dates in the current month. select * from mytable where extract(month from mydate) = extract(month from now()) and extract(year from mydate) = extract(year from now()); Sorry; I was not thinking

Re: [SQL] First day of month, last day of month

2008-04-24 Thread Frank Bax
Nacef LABIDI wrote: is there a better method to retrieve all the rows with dates in the current month. select * from mytable where extract(month from mydate) = extract(month from now()) and extract(year from mydate) = extract(year from now()); -- Sent via pgsql-sql mailing list (pgsql-sql@p

Re: [SQL] Counting days ...

2008-03-15 Thread Frank Bax
Aarni Ruuhimäki wrote: So the WHERE clause would go like: group_id = 1 AND res_start_day < '$date1' AND res_end_day >= '$date1' [AND region_id = $region_id] [AND company_id = $company_id] [AND product_id = $product_id] OR group_id = 1 AND res_start_day = '$date1' AND res_end_day >= '$date1' [

Re: [SQL] Counting days ...

2008-03-14 Thread Frank Bax
Aarni Ruuhimäki wrote: Thanks Frank, astart_day before period_start, end_day before period_start This I don't have to care about as it is not in the period we are looking at. bstart_day = period_start, end_day = period_start Is zero days/nights, ignored. Not even possib

Re: [SQL] Counting days ...

2008-03-14 Thread Frank Bax
Frank Bax wrote: Aarni Ruuhimäki wrote: Anyway, I have to rethink and elaborate the query. I know that it will usually be on a monthly or yearly basis, but a reservation can actually be any of the following in relation to the given (arbitrary) period: 1. start_day before period_start

Re: [SQL] Counting days ...

2008-03-14 Thread Frank Bax
Aarni Ruuhimäki wrote: Check my work, but I think the sum part of the query simply becomes: sum ( ( date_smaller(res_end_day, '2008-02-29'::date) - date_larger(res_start_day, '2008-01-31'::date) ) * group_size ) Basically remove the "+1" so we don't include both start and end dates but

Re: [SQL] how do I get table DDL from psql (not from pg_dump)

2008-02-27 Thread Frank Bax
Sofer, Yuval wrote: I need to extract table DDL (create script) from database connection (using sql, by retrieving system table info or by activating some pg function) This command should output the SQL you need... echo '\d tablename' | psql -E ---(end of broadcast

Re: [SQL] regex_replace problem

2008-01-25 Thread Frank Bax
Gary Stainburn wrote: Hi folks. I've got a problem with regex_replace. The function is regexp_replace - you misspelled it. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] date format

2008-01-25 Thread Frank Bax
nventory(item_id,purchase_date) values(1,"2008 7 22 {} {} {} {DD MONTH }") I would change it to something like: insert into tbl_inventory(item_id,purchase_date) values(1,regexp_replace('2008 7 22 {} {} {} {DD MONTH }','{.+} *','&#x

Re: [SQL] update on join ?

2007-11-21 Thread Frank Bax
Andreas wrote: I'd like to update a table efficiently where the relevant select-info is in another table that is foreign-linked. Stupid example. 2 tables: things (thing_id integer, name varchar(100), color varchar(100)) inventory (item_id integer, thing_fk integer references things (thing_id

Re: [SQL] Funny date-sorting task

2007-05-12 Thread Frank Bax
At 07:40 PM 5/12/07, Andreas wrote: I've got a stack of tasks to show in a list. Every task has a timestamp X that may be NULL or a date. It contains the date when this tasks should be done. Sometimes it has date and the time-part, too. The list should be like this: 1) X sometime today s

Re: [SQL] Joins on many-to-many relations.

2007-03-14 Thread Frank Bax
At 11:39 AM 3/14/07, Wiebe Cazemier wrote: Consider this scenario of three (simplified) tables: people - id - name accounts - id - owner_id REFERENCES people account_co_owners - co_owner_id REFERENCES people - account_id REFERENCES accounts I need a query that allows the user to search for ac

Re: [SQL] PostgreSQL to Oracle

2007-03-09 Thread Frank Bax
At 12:54 PM 3/9/07, Ezequias Rodrigues da Rocha wrote: Is it a simple action to convert a database from PostgreSQL to Oracle ? I mean a simple database with 33 tables 8 functions 31 sequencies 2 triggers 1 type 3 views Has someone any idea ? Depends on what's actually in the above objects;

Re: [SQL] Statistics

2007-03-09 Thread Frank Bax
At 12:22 PM 3/9/07, Ezequias Rodrigues da Rocha wrote: Does someone have statistcs from PostgreSQL ? Numbers from the list, performance statistics. I must argue with another person the idea of do not put Oracle in our organization. Performance should not be the *only* consideration when compa

Re: [SQL] alias not applied

2007-02-09 Thread Frank Bax
At 11:04 AM 2/9/07, Sabin Coanda wrote: I have two queries: 1. SELECT i AS "PK_ID", d AS "Deleted" FROM ( SELECT 52 AS i, true AS d ) x ORDER BY i 2. SELECT i AS "PK_ID", d AS "Deleted" FROM ( SELECT 49 AS i, true AS d UNION SELECT 51 AS i, true AS d ) x ORDER BY i The first returns the colum

Re: [SQL] Droping indexes

2007-01-16 Thread Frank Bax
At 11:27 AM 1/16/07, Frank Bax wrote: At 10:42 AM 1/16/07, Mario Behring wrote: Thank you for your advise..I was thinking about doing exactly that, I wasn't sure on how to do it though, meaning, considering the info below, how should I use the CREATE INDEX command to create

Re: [SQL] Droping indexes

2007-01-16 Thread Frank Bax
At 10:42 AM 1/16/07, Mario Behring wrote: Thank you for your advise..I was thinking about doing exactly that, I wasn't sure on how to do it though, meaning, considering the info below, how should I use the CREATE INDEX command to create these indexes?? This might provide a clue:

Re: [SQL] Case Preservation disregarding case sensitivity?

2006-10-27 Thread Frank Bax
At 07:23 PM 10/27/06, beau hargis wrote: I am aware of the double-quote 'feature' which indicates that an element should be treated in a case-sensitive way. This as been the 'answer' to every question of this sort. This 'feature' does not solve the problem and introduces other problems. If you

Re: [SQL] deleting rows in specific order

2006-10-09 Thread Frank Bax
At 04:14 PM 10/9/06, Daniel Drotos wrote: What is the best way to do something like: delete from tablename where something order by somefield... You cannot, because it doesn't make sense. The "order by" clause is not valid on delete statement. Queries from other processes that start while

Re: [SQL] How to find entries missing in 2nd table?

2006-07-11 Thread Frank Bax
At 10:19 AM 7/11/06, [EMAIL PROTECTED] wrote: control: controller_id pk; datapack: controller_id fk; I need to get all entries from the table control that are not listed in datapack. select controller.controller_id from controller left join datapack on contr

Re: [SQL] How to get a result in one row

2006-06-21 Thread Frank Bax
At 02:24 PM 6/21/06, Richard Broersma Jr wrote: > >I'd like to get the result in only one row: > >id | nick > >--+-- > >22192 | A,T > This question is in the archives (probably more than once). The answer is...> > Read the online docs about aggregate functions. There is an exampl

Re: [SQL] How to get a result in one row

2006-06-21 Thread Frank Bax
At 11:06 AM 6/21/06, [EMAIL PROTECTED] wrote: returns: id | nick --+-- 22192 | A 22192 | T (2 rows) I'd like to get the result in only one row: id | nick --+-- 22192 | A,T This question is in the archives (probably more than once). The answer is... Read the online docs

Re: [SQL] Displaying first, last, count columns

2006-06-21 Thread Frank Bax
At 10:55 AM 6/21/06, Worky Workerson wrote: I'm having a bit of a brain freeze and can't seem to come up with decent SQL for the following problem: I have a table "t" of the form "time_occurred TIMESTAMP, prog_data VARCHAR" and would like to create a query that outputs something of the form "fi

Re: [SQL] Finding multiple events of the same kind

2006-06-11 Thread Frank Bax
At 08:53 AM 6/11/06, Leif B. Kristensen wrote: I've got two tables: CREATE TABLE events ( event_idINTEGER PRIMARY KEY, tag_fk INTEGER NOT NULL REFERENCES tags (tag_id), place_fkINTEGER NOT NULL REFERENCES places (place_id), event_date CHAR(18) NOT NULL DEFAULT '000

Re: [SQL] Field length ??

2006-04-20 Thread Frank Bax
At 05:16 AM 4/20/06, Markus Schaber wrote: Hi, Louise, Louise Catherine wrote: > Could anyone explain, why the field length must be add by 4 : > result 1 : 10 + 4 =14 > result 2 : 5 + 4 = 9 I guess that it is because all variable length datatypes (and text types are such) internally contain a

Re: [SQL] Non Matching Records in Two Tables

2006-02-08 Thread Frank Bax
At 04:10 PM 2/8/06, Ken Hill wrote: I need some help with a bit of SQL. I have two tables. I want to find records in one table that don't match records in another table based on a common column in the two tables. Both tables have a column named 'key100'. I was trying something like: SELECT co

[SQL] REPOST:Memory Allocation error using pg_dump on 7.4

2006-01-27 Thread frank church
I repeatedly get this error whenever I try to backup a database The command used is: pg_dump -Fc -O -U username tablename > tablename.20060122 pg_dump: ERROR: invalid memory alloc request size 4294967290 pg_dump: SQL command to dump the contents of table "cc_ratecard" failed: PQendcopy() faile

Re: [SQL] how to transform list to table and evaluate an

2006-01-07 Thread Frank Bax
Today's your lucky day (I think), because I was looking for (and used) the aggregate function mentioned below just before reading your question. At 11:03 AM 1/7/06, Tomas Vondra wrote: 1) How to create a "table" in the form documtent_id | word_1 | word_2 | ... | word_n -

[SQL] Loading lots of data in a SQL command

2006-01-03 Thread frank church
feature that allows which allows the same performance as transactions, without causing the whole process to fail, like a delayed updates or write mechanism of some sort. It is something I would like to set in that particular data looad. Frank

Re: [SQL] Help with simple query

2005-12-28 Thread Frank Bax
At 06:58 PM 12/28/05, Collin Peters wrote: The following query will return me all the latest dates, but I can't return the note_id or subject with it. SELECT n.user_id, max(n.modified_date) FROM notes n GROUP by n.user_id ORDER BY n.user_id Is this simpler than I am making it? No, it's not "s

[SQL] Does VACUUM reorder tables on clustered indices

2005-12-18 Thread frank church
Does VACUUMing reorder tables on clustered indices or is it only the CLUSTER command that can do that? / r church This message was sent using IMP, the Internet Messaging Program. ---(end of broadcast)

Re: [SQL] select count of distinct rows

2005-12-10 Thread Frank Bax
At 07:53 PM 12/10/05, Havasvölgyi Ottó wrote: I would like to select the count of distinct rows in a table. SELECT COUNT(DISTINCT *) FROM mytable; This does not work. How can I do it with Postgres? select count(*) from (select distinct * from mytable) as x; --

Re: [SQL] How to change database owner in PostgreSQL 7.4?

2005-11-29 Thread frank church
Quoting Andreas Kretschmer <[EMAIL PROTECTED]>: > frank church <[EMAIL PROTECTED]> schrieb: > > > Hi guys, > > > > What is the command change database owner in PostgreSQL 7.4? > > ALTER DATABASE foo OWNER TO blob; I tried that and it didn't work. T

Re: [SQL] Anual Query

2005-11-28 Thread Frank Bax
At 11:20 AM 11/28/05, Mauricio Fernandez A. wrote: Can any of you help me with this query?, I need to retrieve the sum(units) and sum(cost) for each client in every month in the same row, something like this: client|UnJan|CostJan|UnFeb|CostFeb|UnMar|CostMar ...|UnDec|CostDec - -

[SQL] How to change database owner in PostgreSQL 7.4?

2005-11-26 Thread frank church
Hi guys, What is the command change database owner in PostgreSQL 7.4? This message was sent using IMP, the Internet Messaging Program. ---(end of broadcast)--- TIP 9: In versions b

Re: [SQL] cli in sql?

2005-11-11 Thread Frank Bax
At 03:03 PM 11/11/05, Greg Sabino Mullane wrote: At 08:57 AM 11/11/05, Frank Bax wrote: > If my database has column containing a filename, can I use sql to present > this filename and datemodified (as output from 'ls -l' or from mtime() > fuction) or *must* it be done

[SQL] cli in sql?

2005-11-11 Thread Frank Bax
If my database has column containing a filename, can I use sql to present this filename and datemodified (as output from 'ls -l' or from mtime() fuction) or *must* it be done after the query in interface such as php or perl? ---(end of broadcast)

[SQL] Extract table columns in tabular form

2005-11-05 Thread frank church
How do you extract postgresql column names, types and comments in tabular form, using an SQL command?. I know they are stored in one of the system tables, but I don't know which. R Church This message was sent using IMP, the Inter

Re: [SQL] combining records from a single table and presenting

2005-10-27 Thread Frank Bax
At 02:00 PM 10/27/05, Abhishek wrote: I have a table "TABLE1" which has Callguid | digits | type 123 'a' 345

Re: [SQL] SEVEN cross joins?!?!?

2005-10-19 Thread Frank Bax
At 09:04 AM 10/13/05, Daryl Richter wrote: Frank Bax wrote: [snip] Richard, you've summed it up nicely. Splitting locations into subsets (like 2,2,3) doesn't work because it is possible that low values in one location can be offset by high values in another location, and still re

Re: [SQL] SEVEN cross joins?!?!?

2005-10-12 Thread Frank Bax
At 09:00 AM 10/12/05, Daryl Richter wrote: Richard Huxton wrote: Frank Bax wrote: Are you saying that you WANT to generate a cross-join, score the millions of results and then pick the best 10? It's doing what you want, but you'd like it to be faster. Or are you saying that you

Re: [SQL] SEVEN cross joins?!?!?

2005-10-11 Thread Frank Bax
At 08:29 AM 10/11/05, Richard Huxton wrote: Frank Bax wrote: I have a table with only 434 rows in it. Two important columns are "itemid" and "locn". Each item must be in one of seven locations. We need to create a "combo" by selecting one item from each of se

[SQL] SEVEN cross joins?!?!?

2005-10-11 Thread Frank Bax
I have a table with only 434 rows in it. Two important columns are "itemid" and "locn". Each item must be in one of seven locations. We need to create a "combo" by selecting one item from each of seven locations; then determine which "combo" is the "best" according to our analysis (see below

Re: [SQL] Selecting records not present in related tables

2005-10-06 Thread Frank Bax
At 03:43 PM 10/6/05, Hector Rosas wrote: Hello, I'm trying to select records in a table not present in a related table, in example, I've a table with message information (subject, message, date, etc) and another (usermessages) with where user(s) has that message, its state, etc. Records in thi

Re: [SQL] Help with simple SQL query?

2005-10-05 Thread Frank van Vugt
parent_order_id) as foo where order_id = parent_order_id and order_price != sum_price This should prove to be as efficient as it gets ;) -- Best, Frank. ---(end of broadcast)--- TIP 4: Have you searched our list archives

Re: [despammed] [SQL] converting varchar to integer

2005-08-17 Thread Frank Bax
At 05:30 AM 8/17/05, Kretschmer Andreas wrote: [EMAIL PROTECTED] <[EMAIL PROTECTED]> schrieb: > Hi, > >I have a varchar column, and I need to > >1) check the value in it is an integer >2) get the integer value (as integer) test=# update foo set n = substring(t , '[0-9]')::int; I

Re: [SQL] Caracter é

2005-08-06 Thread Frank Finner
/ utf_decode. We had a similiar problem, since we encode both, webpages and database, as utf8, there is no longer such a problem. We use php 4.4.x, postgresql 8.0.3 and pear. Regards, Frank. On Sat, 06 Aug 2005 22:58:40 +0200 Nicolas Cornu <[EMAIL PROTECTED]> thought long, then sat down and

[SQL] Using subselects as joins in POstgeSQL (possible?, examples)

2005-07-22 Thread frank church
where (in table criteria) I have a feeling it is possible but I need the right syntax //Frank This message was sent using IMP, the Internet Messaging Program. ---(end of broadcast

Re: [SQL] Possible to use a table to tell what table to select from?

2005-07-14 Thread Frank Hagstrom
On 7/14/05, Richard Huxton wrote: > Frank Hagstrom wrote: > > Hello > > > > I've been thinking on a potential problem I might get in a distant > > future, but once I started thinking on it I just as well had to > > check... > > > > Is it possibl

[SQL] Possible to use a table to tell what table to select from?

2005-07-13 Thread Frank Hagstrom
r storing large blobs and such?) /Frank H ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

Re: [SQL] Function or Field?

2005-05-03 Thread Frank Bax
is a nice trick, but not useful in this case because all rows for one client are being retrieved anyway for the other three data items. Frank ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] weird SQL statement question

2005-04-23 Thread Frank Bax
At 01:55 PM 4/23/05, Tadej Kanizar wrote: Ok, so I installed the latest version of Postresql (8.02) on a WinXP SP2 machine.. My question is why won't the statement SELECT * FROM table work, whereas the statement SELECT * FROM »table« works! And, to explain a bit more, here's another example: IN

Re: [SQL] user connection over tcp

2005-04-18 Thread Frank Habermann
hello again. ok. i can connect over tcp!!! this works! my problem is that i only can connect with trust! if i use password i cant connect. with trustmode i need the right password for the user! frank -- Original-Nachricht -- Von: "Frank Habermann" <[EMAIL PROTECTED]>

[SQL] user connection over tcp

2005-04-18 Thread Frank Habermann
frank habermann ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] Prepared query ?

2005-04-14 Thread Frank Bax
At 10:28 AM 4/14/05, Dinesh Pandey wrote: How can I Write a prepared query and Set values at run time and Execute that query for different values. Depends on what language you are using - try interfaces mailing list.

Re: [SQL] can you change an FK constraint from NOT DEFERRABLE to DEFERRABLE

2005-03-30 Thread frank
On Wed, Mar 30, 2005 at 11:48:31AM +0200, PFC wrote: > > Checks the docs on ALTER TABLE ... ALTER CONSTRAINT ... ALTER CONSTRAINT? I did check for that, and it does not appear to exist?! That's why I asked ... Rgds, Frank ---(end o

[SQL] can you change an FK constraint from NOT DEFERRABLE to DEFERRABLE

2005-03-30 Thread frank
ybe help. Right now we can't try this because all the FK checks where created with default settings. We'd like to avoid taking the database down for recreating foreign keys. Regards, Frank ---(end of broadcast)--- TIP 5: Have you

Re: [SQL] Cast NULL into Timestamp?

2004-12-11 Thread Frank Bax
At 12:11 AM 12/11/04, Josh Berkus wrote: Wei, > insert into table temp (tempname, tempdate) > select distinct 'tempname', null from some_other_relevant_table; I don't think you're reporting the error exactly as it happened. Try cutting and pasting your actual PSQL session into your e-mail. Perhaps

Re: [SQL] 'show databases' in psql way?

2004-11-01 Thread Frank Bax
t I only found the '-l'-way to this this. The -e switch of psql will display queries behind commands. So use this option, the use 'l' as a command instead of a switch. Frank ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] LIKE '%%' does not return NULL

2004-08-15 Thread Frank Finner
gt; false", you will only get the fields containing true, not the NULLs. Regards, Frank. On Wed, 11 Aug 2004 13:22:00 +1200 "Traci Sumpter" <[EMAIL PROTECTED]> sat down, thought long and then wrote: > A team developer has chosen the lazy way of not checking if a variable &g

Re: [SQL] date_format in postresql

2004-07-21 Thread Frank Bax
Check your version with: select version(); In the meantime, you could try date_part('epoch', submittime) which will return a unix timestamp, you could then use functions within your scripting language to convert to human readable date formats. Frank At 11:53 PM 7/20/04,

  1   2   >