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] 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 -0.037131s

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

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

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
Devil™ Dhuvader wrote: its like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the entry that has sum > $500. If there is some user who didnt even make 500 till now in my shop return the first date of transaction/order . ex: Orders(order_id,

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
Montaseri wrote: Given table T1 and columns id, start_date, stop_date and status, propose a query that reports count of items opened and closed . status is an enum including NEW, xxx, , CLOSED. The first status of an item is NEW (could be used in place of start_date) For example Date

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
Terry Lee Tucker wrote: On Monday 04 August 2008 10:05, Richard Broersma wrote: On Mon, Aug 4, 2008 at 6:54 AM, Mike Gould <[EMAIL PROTECTED]> wrote: In some db's if you use a lower() or upr() it will always do a table scan instead of using a index True, this would also happen in PostgreSQL.

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 possible to inser

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
iuri de araujo sampaio wrote: hi, how to change the default format for type date? I have created a field on a table: ## create table tbl_inventory ( item_id integer constraint c_pk primary key, I. purchase_date date, II. fabrication_date date, III. ex

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

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 -

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

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] 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 - -

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)

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: [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] Function or Field?

2005-05-03 Thread Frank Bax
At 07:58 AM 5/3/05, [EMAIL PROTECTED] wrote: Do I have to create another table to put this data??? But, Isn't it redundancy? :-/ The question is: For example: I have a "clients" table and I have a "taxes" table that is a chield of client. Is more efficient put fields into client table that conta

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] 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] 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
At 07:13 AM 11/1/04, Erik Wasser wrote: how can I list the databases in a postgresish way? I know about the '-l' switch of 'psql' but is there a DBI/SQL-query way? I don't want to call an external program only to list the databases. I've googled about this problem but I only found the '-l'-way to t

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, azah azah

Re: [SQL] Normalising an existing table - how?

2004-06-24 Thread Frank Bax
At 02:51 PM 6/24/04, Graham Leggett wrote: I have an existing table containing a column in it containing a money value. I would like to normalise this column into a separate table, as the money value is to be expanded to contain a tax value, etc. I have been trying to find a SQL query that will

Re: [SQL] Last day of month

2004-06-08 Thread Frank Bax
At 11:30 PM 2/25/04, Joe Conway wrote: Greg Sabino Mullane wrote: How to find the last sunday/mon/sat of any given month. There is probably a smoother way to do it, but here is a quick little function to do what you ask. Feed it a date and a number, where 0 is Sunday, 1 is Monday, etc. oops...f

Re: [SQL] isnumeric() function?

2004-04-30 Thread Frank Bax
At 11:29 AM 4/30/04, Yudie wrote: Great the function works, but what does it means? SELECT $1 ~ ''^[0-9]+$'' Yudie The ~ is a pattern matching operator. ^ matches beginning of string [0-9] matches any numeric digit 0 thru 9. + matches one or more occurrences of what came be

[SQL] strange "order by" request

2003-07-23 Thread Frank Bax
Two tables - employee and timesheet simple enough. Each table is more complex than example before. timesheet contains multiple rows per day because the "other" fields are different for various rows on same day/employee. My selection criteria actually uses some of these other fields. lo_shift

Re: [SQL] Functional Indexes

2003-07-15 Thread Frank Bax
The two functions do not group data the same way, so a common index is not possible. urlhost would put pgsql.org and pgsql.com close together. urltld would but pgsql.com and xyz.com close together. Frank At 01:36 PM 7/15/03, David Olbersen wrote: Hello all, I have a function (urlhost) which fi

Re: [SQL] Creating Views with Column Names based on Distinct

2003-06-09 Thread Frank Bax
At 10:59 AM 6/6/03, Damien Dougan wrote: I was wondering if it is possible to create a table view based on a table which is effectively an "attribute list". For example, suppose I have two tables: CREATE TABLE user ( userid integer, username character varying, userpassword character varying,

Re: [SQL] alter column witdh

2003-05-27 Thread Frank Bax
At 10:38 AM 5/27/03, Eric Anderson Vianet SAO wrote: >how can I alter the column width http://techdocs.postgresql.org/techdocs/updatingcolumns.php fbax=# create table tablename (columnname text); CREATE fbax=# \d tablename Table "tablename" Attribute | Type | Modifier +--+-

Re: [SQL] convert from an integer to a date

2003-02-17 Thread Frank Bax
At 04:33 PM 2/14/03, [EMAIL PROTECTED] wrote: When I run select to_date('20030212','MMDD') the output is 2/12/03 if I run select to_date( to_char(20030212,),'MMDD'); the output is 6/23/05 How can I convert from integer into date format correctly? Same as the first one, except l

Re: [SQL] union query doubt:

2002-12-11 Thread Frank Bax
At 11:21 AM 12/11/02, javier garcia wrote: I've got a table with three fields: DATE, POINT, FLOW. The POINT field can have values among 1 and 6. So, for a same date I have six different points with the correspondings flows. I would like to make a query to obtain something like: DATE POINT1 POINT2

Re: [SQL] Backup to data base how ?

2002-12-11 Thread Frank Bax
At 10:36 PM 12/11/02, ksql wrote: This is vital for my, please send me an example about like I can make me to support my database with name WAREHOUSE pg_dump -o -c warehouse | gzip > warehouse.gz http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/backup.html

Re: [SQL] how can I improve the speed of this query

2002-11-19 Thread Frank Bax
Problem could be the SeqScan on visitor (very last line of explain). This appears to be coming from the last join in your query. Does an index on ID exist on Visitor table? Does changing: WHERE "VisitorExtra"."ID"="Visitor"."ID" AND "VisitorExtra"."ID"= 325903; to

Re: [SQL] VARCHAR vs TEXT

2001-10-16 Thread Frank Bax
Perhaps 'limits' should be part of FAQ, not separate entity? Also a reference (or link) to 'limits' from other sections such as mentioned below may be more appropriate than duplicating the information. Frank At 08:56 AM 10/16/01 -0400, you wrote: >> > "BM" == Bruce Momjian <[EMAIL PROTECTED

Re: [SQL] Order by email address by domain ?

2001-05-10 Thread Frank Bax
Why is everyone else suggesting new functions? This works (in 6.5.3): ORDER BY lower(substring(email from position('@' in email)+1 )), lower(email) remove the lower() functions if you don't need them (I had mixed case addresses). I am guessing/assuming that it's cheaper to just use entire e

Re: [SQL] COUNT

2000-10-19 Thread Frank Bax
Select count(*) from Table At 04:58 AM 10/20/00 +, Craig May wrote: >Hi, > >How do I get a row count, like "Select [COUNT] from Table" ?? > >Regards, >Craig May > >Enth Dimension >http://www.enthdimension.com.au > >

Re: [Fwd: Re: [SQL] no ORDER BY in subselects?]

2000-09-21 Thread Frank Bax
At 11:29 AM 9/21/00 +1000, you wrote: >The main reason I use them is to find the 'next' or 'previous' record in a >list (eg. next date, next ID). eg. > > select , (select ID from table where id > this.id > order by id asc limit 1) as next_id ... Doesn't this give the same result (without order

Re: [SQL] making two columns out of one

2000-09-12 Thread Frank Bax
LSE (hi_shift-lo_shift) END) AS ovrhrs FROM timesheet GROUP BY emp ORDER BY emp; At 09:34 AM 9/11/00 -0400, Frank Bax wrote: >I've got a table containing some timesheet data. >Fields are emp, earncode, lo_shift, hi_shift. > >SELECT emp, sum(hi_shift - lo_shift) as reghrs fr

[SQL] making two columns out of one

2000-09-11 Thread Frank Bax
I've got a table containing some timesheet data. Fields are emp, earncode, lo_shift, hi_shift. SELECT emp, sum(hi_shift - lo_shift) as reghrs from timesheet where earncode in ('R', 'C', 'X') order by emp will give me all the regular hours SELECT emp, sum(hi_shift - lo_shift) as ovrhrs from tim

Re: [SQL] Creating timestamps in queries?

2000-07-11 Thread Frank Bax
I think you meant: select * from blah where stamp >= now() - '7days'::interval; You can also try: select * from blah where age( now(), stamp ) < '7days'::interval; Frank At 09:07 AM 7/11/00 +0200, you wrote: >Hi Rob, > >Try this: > >select * from blah where stamp >= now()::date - 7; > >I thin