Re: [SQL] Unique index VS unique constraint

2013-10-04 Thread Steve Grey
Unique indexes can be partial, i.e. defined with a where clause (that must be included in a query so that PostgreSQL knows to use that index) whereas unique constraints cannot. JORGE MALDONADO wrote > I have search for information about the difference between "unique index" > and "unique constrain

Re: [SQL] how can I replace all instances of a pattern

2013-03-26 Thread Steve Crawford
t I cannot find any function that will replace all instances of a string AND can base it on a regular expression pattern. Is there a better way to do this in 9.1? You were on the right track with regexp_replace but you need to add a global flag: regexp_replace(column_name,'\W','','g') See examples under http://www.postgresql.org/docs/9.1/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP Cheers, Steve

Re: [SQL] Split a string to rows?

2013-01-07 Thread Steve Crawford
On 01/07/2013 11:44 AM, Emi Lu wrote: Is there a function to split a string to different rows?... Have you looked at regexp_split_to_table? Cheers, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref

Re: [SQL] Simple Upgrade from PostgreSQL version 8.1.11 (With schemas)

2012-07-10 Thread Steve Crawford
u get to a newer version (anything past 8.3? 8.4) you can use the new upgrade tools moving forward to minimize downtime during the upgrade process but you will *always* need to test and evaluate before deploying. Cheers, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make

Re: [SQL] Simple way to get missing number

2012-04-24 Thread Steve Crawford
eries(1,15) as allnumbers where allnumbers not in (select anumber from fooo); They all give you the same result. The "right" choice will depend on the size of your table, how it is indexed, how fully it is populated and even on your version of PostgreSQL. (Apologies for the funky fi

Re: [SQL] Simple way to get missing number

2012-04-24 Thread Steve Crawford
4 6 8 10 12 14 Cheers, Steve -- 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] how to concatenate in PostgreSQL

2012-03-27 Thread Steve Crawford
On 03/27/2012 07:48 AM, Rehan Saleem wrote: well i am quite sure its PostgreSQL forum and it is obvious, i am asking this to concatenate in plpgsql. *From:* Steve Crawford *To:* pgsql-sql@postgresql.org *Sent:* Monday

Re: [SQL] how to concatenate in PostgreSQL

2012-03-26 Thread Steve Crawford
e1 where userid=' + 5 exec(sqi) where 5 is the userid from table1 thanks Cheers, Steve

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

2012-03-20 Thread Steve Crawford
statements that need a longer timeout you can change just for those statements. Cheers, Steve -- 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] time interval math

2012-02-08 Thread Steve Crawford
g intervals across DST boundaries, have changed over time. IIRC most of those changes were pre-8.3 but haven't looked recently. Cheers, Steve -- 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] querying a column w/ timestamp with timezone datatype

2012-01-30 Thread Steve Crawford
you are thinking about a *time* with time zone (a type that exists due to SQL requirements but which is a somewhat nonsensical type, the use of which is not recommended): http://www.postgresql.org/docs/9.1/static/datatype-datetime.html#DATATYPE-TIMEZONES Cheers, Steve -- Sent via pgsql-sql mailin

Re: [SQL] Update Mass Data in Field?

2012-01-26 Thread Steve Crawford
ression match and regexp_replace to ensure that the pattern is anchored at the end of the field and includes the "@" sign in the expression to avoid accidentally matching something like ...@theholyghost.org. You can always do a select of the emp_email alongside the replacement express

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Steve Crawford
much other goodness. Cheers, Steve -- 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] Unable To Modify Table

2012-01-12 Thread Steve Crawford
raint? Try updating the values in both tables within a transaction with constraints set to deferred: http://www.postgresql.org/docs/current/static/sql-set-constraints.html Cheers, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription:

Re: [SQL] compare table names

2012-01-09 Thread Steve Crawford
with extra work to properly handle the first 10-days of each year. Alternately, you could have a separate table that just tracks the creation dates of the temporary tables and be free from any requirement to have dates be part of the table names. Cheers, Steve -- Sent via pgsql-sql mailing li

Re: [SQL] internal format of timstamp?

2011-12-29 Thread Steve Crawford
spect that your first step should be to check pg_config to see if the server from which you are attempting to recover data was compiled with --enable-integer-datetimes. Cheers, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription:

[SQL] plpgsql function executed multiple times for each return value

2011-10-08 Thread Steve Northamer
get "invalid reference to FROM-clause entry for table apps". So my questions are: 1) How do we cause the paymentcalc function to be executed only once? and 2) How do we call a table returning function with inputs from a table? Thank you very much! Steve -- Sent via pgs

Re: [SQL] how to calculate differences of timestamps?

2011-09-27 Thread Steve Crawford
ndexes though an index on ts will probably suffice for most cases. Cheers, Steve -- 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] Mysterious column "name"

2011-08-09 Thread Steve Crawford
http://www.postgresql.org/docs/9.0/static/rowtypes.html on composite data types and scroll to section 8.15.3. Cheers, Steve -- 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] why these results?

2011-08-01 Thread Steve Crawford
~~* '%text%'; count --- 98 (1 row) Shouldn't it be 99? That is out of 100 records there is one that has "text" in column "col" so the !~~* should return 99 rows. ?? -wes select count(*) from table where col is null; (null is neither equal nor not-equal to

Re: [SQL] How to remove a set of characters in text-columns ?

2011-06-30 Thread Steve Crawford
string ''. There might be a more elegant way. Is there ? regards Look at regexp_replace() http://www.postgresql.org/docs/9.0/static/functions-string.html http://www.postgresql.org/docs/9.0/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP Cheers, Steve -- Sent vi

Re: [SQL] self join

2011-05-16 Thread Steve Crawford
On 05/14/2011 07:36 PM, Jasen Betts wrote: use the "NOT IN" operator with a subquery to retch the disallowed values Hmmm, "retch" as a synonym for "output"? I've seen more than one case where that is an appropriate description. :) Cheers, Steve -- Sen

Re: [SQL] convert in GMT time zone without summer time

2011-05-03 Thread Steve Crawford
nes but it would be well worth your time to carefully read http://www.postgresql.org/docs/8.4/interactive/datatype-datetime.html (IIRC, you are using 8.4) a couple times. Cheers, Steve -- 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] convert in GMT time zone without summer time

2011-04-18 Thread Steve Crawford
RT_TO_UTC( '2011-03-22 14:17:00+01'::timestamptz ,'CET'),'-mm-dd hh24:MI:SS') AS winter, to_char(CONVERT_TO_UTC( '2011-04-22 14:17:00+02'::timestamptz ,'CET'),'-mm-dd hh24:MI:SS') AS summer; If you can use the correct time zone name, ever

Re: [SQL] Cumulative result with increment

2011-02-07 Thread Steve Crawford
27; else 'night' end as shiftname This can be used for grouping as well as display. Cheers, Steve -- 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] Question about PQexecParams

2010-09-22 Thread Steve
Original-Nachricht > Datum: Sun, 12 Sep 2010 01:52:04 +0400 > Von: Dmitriy Igrishin > An: Steve > CC: pgsql-sql@postgresql.org > Betreff: Re: [SQL] Question about PQexecParams > Hey Steve, > > 2010/9/11 Steve > > > Hello list, > > &

Re: [SQL] Question regarding indices

2010-09-12 Thread Steve
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

Re: [SQL] Question regarding indices

2010-09-11 Thread Steve
Original-Nachricht > Datum: Sat, 11 Sep 2010 11:04:16 -0400 > Von: Tom Lane > An: "Steve" > CC: pgsql-sql@postgresql.org > Betreff: Re: [SQL] Question regarding indices > "Steve" writes: > > I have a small question about the o

Re: [SQL] Question regarding indices

2010-09-11 Thread Steve
Original-Nachricht > Datum: Sat, 11 Sep 2010 10:05:18 -0400 > Von: Michael Gould > An: Steve > Betreff: Re: [SQL] Question regarding indices > Steve, > Hello Michael, > If I remember correctly the sort only works on the final result set and so >

[SQL] Question about PQexecParams

2010-09-11 Thread Steve
Can any one help me with this? // Steve -- GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] Question regarding indices

2010-09-11 Thread Steve
the SQL query with ordered data influence the speed of the query? // Steve -- GRATIS: Spider-Man 1-3 sowie 300 weitere Videos! Jetzt freischalten! http://portal.gmx.net/de/go/maxdome -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http

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

2010-08-04 Thread Steve Wampler
something wrong there. I saw very bad clock performance on one Linux box I had (dual-single core AMD cpus, no VMs), even with NTP, until I changed the clocksource kernel parameter to hpet. Unfortunately (or fortunately) I no longer have that box. -- Steve Wampler -- swamp...@noao.edu The gods that

[SQL] creating a versioning system for sets?

2010-04-20 Thread Steve Lefevre
I'm working on a web app for a quality control checklist. I already have a table set up, but I have a hunch that our model is sub-optimal and I could get some better performance.I'm hoping someone on this list can help me think clearly about how to express this efficiently in SQL. Each checklist h

Re: [SQL] Table Design for Hierarchical Data

2010-04-06 Thread Steve Crawford
is that the multi-table scenario will be better suited to flagging aggregates for suppression. Cheers, Steve -- 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] LIMIT 1; The Integer part only

2009-09-03 Thread Steve Crawford
integer part of the number, which math function can do this for me? For example, I have 3.900 and I need only the 3 (the integer part), which math function to be used? floor(3.900) Cheers, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription

Re: [SQL] Month/year between two dates

2009-08-11 Thread Steve Crawford
nt1::text || '-' || int2::text || '-1')::date and date_trunc('month', date_to) >= (int1::text || '-' || int2::text || '-1')::date ... Cheers, Steve -- 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] SQL report

2009-07-30 Thread Steve Crawford
is moved from the "current" to the "historical" table and the new one added to the "current" table. The latest status report will only need a simple join on the "current" table with a max size of 100,000 rather than a more complex query over a 100,000,0

Re: [SQL] it's not NULL, then what is it?

2009-06-30 Thread Steve Crawford
... canon=# select count(maf) from gallo.sds_seq_reg_shw canon-# where maf ISNULL; count --- 0 (1 row) I believe count will only count not-null anyway so this will always return zero. Try count(*) instead of count(maf). Here's an example: st...@[local]=> select * from

Re: [SQL] How to count from a second table in an aggregate query?

2009-04-17 Thread Steve Midgley
Date: Wed, 15 Apr 2009 21:23:04 -0700 From: Steve Midgley To: Erik Jones Subject: Re: How to count from a second table in an aggregate query? Message-ID: <49e6b2a8.5040...@misuse.org> Erik Jones wrote: > > On Apr 15, 2009, at 1:15 PM, Steve Midgley wrote: > >>

Re: [SQL] How to count from a second table in an aggregate query?

2009-04-15 Thread Steve Midgley
Erik Jones wrote: On Apr 15, 2009, at 1:15 PM, Steve Midgley wrote: I want to generate an analysis report that counts the values in two separate tables. I've been able to accomplish what I want with two separate queries that I then merge together in Excel. Essentially what I need

[SQL] How to count from a second table in an aggregate query?

2009-04-15 Thread Steve Midgley
both queries side-by-side along with the FK id's in a single result set Thanks for any assistance on this! Steve /*SQL STARTS*/ drop table if exists contact_log; drop table if exists contact_property; create table contact_log(id serial NOT null, src_contact_id integer, log_type character

Re: [SQL] changing multiple pk's in one update

2009-04-14 Thread Steve Midgley
3,4 for the ordering, but then you have to mess with two records in order to swap the positions of (say) item 2 and 3. Of course you can do this pretty easily inside a transaction, and you don't have to worry about the mess of moving PK's. Steve -- 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] Nested selects

2009-04-09 Thread Steve Midgley
reason. How about this: select round.*, stage.name from round left join stage on stage.id = round.stage_id ORDER BY round.score DESC; Steve -- 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] Can we load all database objects in memory?

2009-03-26 Thread Steve Midgley
sks these days, but for a read-only database, that seems like an option (10gb of ram disk for your read-only data and 6 gb of ram for OS and Pg). Steve -- 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] Alter Table/Indexing

2009-03-25 Thread Steve Midgley
rebuilding them manually later? Thanks for any insight on that (and I hope my question helps the OP as well - if this seems off topic let me know), Steve -- 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] Exclude fields from SELECT command

2009-03-17 Thread Steve Midgley
ot;table_name" and then looking at all the "column_name" fields, building your column list, excepting the column_names you wish to exclude.. Best, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] Re: select count of all overlapping geometries and return 0 if none.

2009-03-13 Thread Steve Midgley
y'), ('Rob Roy', '(2,0)', 'today'), ('Rob Roy', '(2,0)', 'today'); -- SOLUTION QUERY HERE -- select count(user_tracker.id), locations.name from user_tracker right outer join locations on user_tracker.location <@ locations.area group by locations.name; -- END SQL SCRIPT -- OUTPUT: 3;"Manhattan, NY" 0;"Talahassee, FL" 6;"Frankfurt, GE" Steve -- 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] Best practices for geo-spatial city name searches?

2009-02-25 Thread Steve Midgley
ors for this along with a GiST index - it's not perfect for long distances - it assumes the earth is flat, but it works great for small distances and is very fast). I hope this helps. Feel free to contact me on-list or off, if you want to discuss more. Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] Stored Procedure Generator?

2009-02-17 Thread Steve Nyemba
such a utility I would like it to be reviewed/evaluated? Thanks a lot guys. -- "If you would take, you must first give, this is the beginning of intelligence" -- Lao Tze, Tao Te Ching Steve L. Nyemba -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make chang

Re: [SQL] problem using twice custom comparision operator

2009-01-25 Thread Steve Midgley
nce would be anything comparable either (I'd guess that using the "regex" operators (like "~*" would be the way to go). I thought I'd mention this other approach in case it was of interest and you haven't run across it before. Sincerely, Steve -- Sent

[SQL] Re: some howto/theory book/tutorial on practical problem solving in SQL

2009-01-14 Thread Steve Midgley
d solutions, questions and ideas back to this list as you go. I've forwarded this thread already to several people who work with related issues, and they're very interested in some solutions as well. So stay in touch as you work on this, please. Sincerely, Steve -- Sent via pgsql-sql

Re: [SQL] How to excute dynamically a generated SQL command?

2009-01-05 Thread Steve Midgley
works even on the command line, which is helpful. You can type this directly into the CMD prompt now: dir "c:/temp" All new programs I write on Windows (in Ruby) use forward slashes for paths, and it works just fine. Not sure about VB or C#, but I'd guess you can make it work. Might be simpler than all the escaping work.. Best, Steve -- 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] Question on Escape-string

2009-01-03 Thread Steve Midgley
; CREATE TABLE test ( filename character varying(255) NOT NULL, data bytea ); insert into test (filename, data) values (E'c:\\tmp\\tst.tif', '1234'); select replace(filename, E'\\', E''), data from test Does this do it? Steve -- Sent via pg

Re: [SQL] Re: How to insert Images(bnp,png,etc) into Postgresql and how to retrive the inserted Imaged using C#.net

2008-12-18 Thread Steve Crawford
t;Working with binary data and bytea datatype" and try the example code there. Just feed it your images as input and all should be good. Cheers, Steve -- 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] Best way to "and" from a one-to-many joined table?

2008-12-07 Thread Steve Midgley
eople_id = p.people_id) JOIN test_attributes b ON ((b."people_id" = p."people_id") WHERE (a."attribute" = @firstAttr)) AND (b."attribute" = @secondAttr)); Also, any suggestions about how to figure out this on my own without bugging the list in the future would be gre

Re: [SQL] wired behaviour

2008-12-01 Thread Steve Crawford
ue, use the coalesce function: select coalesce(my_column, 'a null value'); will return the string 'a null value' whenever my_column is null. Cheers, Steve -- 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] Sequence and nextval problem

2008-11-25 Thread Steve Midgley
having to look up the max value on each one (which would also require that you shut off access to the table and for a much longer time). Hope that helps, Steve -- 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] grouping/clustering query

2008-10-24 Thread Steve Midgley
At 11:28 AM 10/23/2008, Joe wrote: Steve Midgley wrote: # (invoiceid, txid) (A, 1) (A, 3) (B, 1) (B, 2) (C, 5) (D, 6) (D, 7) (E, 8) (F, 8) For journalling, I need to group/cluster this together. Is there a SQL query that can generate this output: # (journal: invoiceids, txids) [A,B

Re: [SQL] grouping/clustering query

2008-10-23 Thread Steve Midgley
n you want two columns of output, each column being a pg array? I may not be the best person to answer the actual SQL question, but I thought I'd clarify your requirements so the list members can have the best chance of answering. Steve -- Sent via pgsql-sql mailing list (pgsql-sql@p

Re: [SQL] many-to-many relationship

2008-10-09 Thread Steve Midgley
morphic join" but I could be wrong about > that. I'd guess you could construct a rule or trigger to validate the > foreign key data on insert/update but that's out of my skill area. Hi Steve, So in your solution the f_table column is just text which needs to be validated by

Re: [SQL] many-to-many relationship

2008-10-07 Thread Steve Midgley
uld construct a rule or trigger to validate the foreign key data on insert/update but that's out of my skill area. Hope that helps a little, Steve -- 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] Finding sequential records

2008-09-29 Thread Steve Midgley
At 09:50 PM 9/29/2008, Richard Broersma wrote: On Mon, Sep 29, 2008 at 7:48 PM, Steve Midgley <[EMAIL PROTECTED]> wrote: > In my specific case it turns out I only had duplicates, but there could have > been n-plicates, so your code is still correct for my use-case (though I

Re: [SQL] Finding sequential records

2008-09-29 Thread Steve Midgley
At 05:38 PM 9/26/2008, Oliveiros Cristina wrote: In-Reply-To: <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Howdy, Steve. SELECT id FROM dummy a NATURAL JOIN ( SELECT fkey_id,name FROM dummy GROUP BY fkey_id,

Re: [SQL] Finding sequential records

2008-09-26 Thread Steve Midgley
aps a natural join like in Oliveiros' sql would do the job? Thanks for any advice on either of these solutions. I'm going to learn a lot here if someone can pound it into my head. Thanks, Steve It seems to be returning any records that have sequential id's regardless At 11:

[SQL] Finding sequential records

2008-09-26 Thread Steve Midgley
uld be a bonus! It seems like there's a clever way to do this without cursors but I can't figure it out! Thanks for any help! Steve -- 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] surrogate vs natural primary keys

2008-09-18 Thread Steve Midgley
great explanation as to the value of natural keys! You haven't won me over, but you did teach me something - which I appreciate. Best, Steve -- 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] surrogate vs natural primary keys

2008-09-17 Thread Steve Midgley
er heard someone say they've been bitten by using an arbitrary surrogate key system, but I myself have been bitten and have heard lots of stories of problems when using natural keys. I hope this helps some, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] What is wrong with this PostgreSQL UPDATE statement??

2008-08-22 Thread Steve Johnson
Sorry for the fairly long post. I'm having a big problem trying to update one table from another in PostgreSQL 8.3.1. I have a lookup table called termgroup: # select * from termgroup; termgroupname | mindays | maxdays ---+-+- 1-30 days | 1 | 30 31-59 d

Re: [SQL] Join question

2008-08-15 Thread Steve Midgley
t against that in WHERE clause? I could be misunderstanding the whole thing though.. Steve -- 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] DELETE with JOIN

2008-08-07 Thread Steve Midgley
metimes in middleware and it works pretty well. There's probably a pure-sql solution in Pg as well but this method should work across any SQL platform, which seems like one of your requirements. Steve -- 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] Problem with ORDER BY and DISTINCT ON

2008-07-31 Thread Steve Midgley
At 03:51 PM 7/31/2008, Tom Lane wrote: Steve Midgley <[EMAIL PROTECTED]> writes: > At 07:29 AM 7/16/2008, Tom Lane wrote: >> I think what is happening is that ORDER BY knows that and gets rid of >> the duplicate entries while DISTINCT ON fails to do so. > Of course rem

Re: [SQL] index for group by

2008-07-22 Thread Steve Midgley
u could aggregate against your datetime stamp by N hours or days as well. If this idea is of interest you can write back to the list or off-list to me for more info. Steve -- 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] Problem with ORDER BY and DISTINCT ON

2008-07-16 Thread Steve Midgley
At 07:29 AM 7/16/2008, Tom Lane wrote: Steve Midgley <[EMAIL PROTECTED]> writes: Interesting. You realize of course that sorting by the same expression twice is completely redundant? I haven't dug through the code yet but Thanks Tom. Yeah, I was a little embarrassed to throw this

[SQL] Problem with ORDER BY and DISTINCT ON

2008-07-16 Thread Steve Midgley
ate_max" CASE is causing the problem. Thanks for any advice or suggestions on how to get this to run correctly. Is this a bug? Basically I'm doing this as an optimization - I can get much better performance running the DISTINCT ON in some circumstances than using DISTINCT, but the edge case above is breaking my tests and preventing me from implementing the idea. The code is generated by an application layer which is not really paying attention to whether or not the two CASE statements apply to the same field or not (sometimes they do sometimes they don't).. Thanks! Steve -- 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] Copyright and Paper walls (was: Rollback in Postgres)

2008-07-12 Thread Steve Midgley
is really important in general for the list. There's a lot of good information out there and I think it's not so great if this list were to limit itself only to public domain and open copyright documentation for consideration. Just two more cents from the peanut gallery on a Sat

Re: [SQL] PERSISTANT PREPARE (another point of view)

2008-07-11 Thread Steve Midgley
lication layer developers with a consistent set of interfaces to obtain data that are not tied to the data tables themselves. And allowing them to insert/update/manage tables via structured interfaces as well. Am I missing something? Best, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@po

Re: [SQL] When was my database created

2008-07-11 Thread Steve Crawford
of the database was created. If you restored from a dump or otherwise recreated the database for any reason (version upgrade, machine migration, disaster recovery, etc.), the timestamps would represent the time of the restore, not the time of the creation of the original database. Cheers, Steve

Re: [SQL] ANSI Standard

2008-06-26 Thread Steve Midgley
orm against ANSI-92 (or any other std) if you do not regularly test against a set of platforms, your solution will converge on supporting only the platforms you do regular test against. I hope that helps, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To ma

Re: [SQL] Sequential event query

2008-06-25 Thread Steve Crawford
Steve Crawford wrote: Allan Kamau wrote: Hi Steve, Am having difficulties (there is a chance I could be the only one) trying to see how the results you've listed under "I would want to get:" section can be generated from the information you have provided in your implicit pr

Re: [SQL] Sequential event query

2008-06-25 Thread Steve Crawford
Allan Kamau wrote: Hi Steve, Am having difficulties (there is a chance I could be the only one) trying to see how the results you've listed under "I would want to get:" section can be generated from the information you have provided in your implicit problem statement. Remember

[SQL] Sequential event query

2008-06-24 Thread Steve Crawford
might be a day or two. I am looking for a query that will list any device having no variation in the recent events. Cheers, Steve -- 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] Tsearch

2008-06-12 Thread Steve Midgley
op search / coding schemes that say things like "find all records with chicken and skin, where the following words do not appear between the words chicken and skin: beef, pork, cow, pig, etc.." Just some thoughts for you there. Best, Steve -- Sent via pgsql-sql m

Re: [SQL] Different type of query

2008-06-11 Thread Steve Crawford
) for a given ndb_no: select nutrient_no,nutrient_value from nutrient_data where ndb_no = 13473 order by nutrient_value limit 5; Cheers, Steve -- 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] Different type of query

2008-06-11 Thread Steve Crawford
from nutrient_data where nutrient_no=203; Cheers, Steve -- 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] Conceptual Design Question

2008-06-10 Thread Steve Midgley
you there. I'm sure others have different perspectives which are equally or more valid! Best, Steve -- 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] design resource

2008-06-06 Thread Steve Midgley
l_accents|short_accents...etc I keep the country names with and without accents to make searching easier across keyboards/locales. I hope this helps too -- I think Craig has given you the lion's share of good advice for sure - and I definitely follow the practices more or less as he laid them

Re: [SQL] How long - Vacumm full - 10 million to 90,000

2008-05-29 Thread Steve Crawford
into yourtable SELECT * from xxx; DROP TABLE xxx; If you are so close to out-of-space on your disk that you don't have the room those 90,000 records will require, you may have to dump/restore using another machine. Cheers, Steve -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.or

Re: [SQL] Extremely Low performance with ODBC

2008-05-27 Thread Steve Midgley
r ADO driver and see if it gives you the same problems.. Just some more grist for the solution mill, hopefully! Steve -- 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] Extremely Low performance with ODBC

2008-05-27 Thread Steve Midgley
gs in ODBC that caused ODBC to do as absolutely little as possible. Just receive raw sql, pipe it to my server and hand it back to me in a memory data structure. All the data structure parsing was done by my middleware connection wrapper to ODBC and none was done by ODBC itself. Once I got

Re: [SQL] Extremely Low performance with ODBC

2008-05-22 Thread Steve Crawford
his caused very poor performance on large tables. EXPLAIN will not reveal this. You might want to set the server to log all transactions and see what the app is really doing at the server level. Cheers, Steve

Re: [SQL] SQL question....

2008-05-21 Thread Steve Midgley
f you index ip's using a custom data type and search/group for specific octets, you'll get much better performance than just searching via a regular b-tree string index.. http://www.postgresql.org/docs/8.3/static/datatype-net-types.html Steve -- Sent via pgsql-sql mailing list (pg

Re: [SQL] numbering rows on import from file

2008-05-02 Thread Steve Crawford
es and rollbacks will cause holes. If you just need consecutive row-numbering on output (not in the table) and if the row numbering doesn't need to match the same record each time, you can create a temporary sequence and select nextval('tempsequence'), from yourtable. Cheers

Re: [SQL] export CSV file through Java JDBC

2008-04-15 Thread Steve Midgley
ommand here"); I think you want something more like this psuedo code: system.set_environment("PGPASSWORD")="pass1234"; system.exec("psql my command here"); I hope this helps, Steve

Re: [SQL] Create on insert a unique random number

2008-03-19 Thread Steve Midgley
clears up what I was recommending! I didn't anticipate it would stir up this much analysis and I hope the OP finds your input and mine useful in coming up with a final answer to his issue. Thanks for taking the time to consider the issue and I'll look forward to any additi

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread Steve Midgley
At 12:36 PM 3/18/2008, D'Arcy J.M. Cain wrote: On Tue, 18 Mar 2008 12:23:35 -0700 Steve Midgley <[EMAIL PROTECTED]> wrote: > 1) Create a second field (as someone recommend on this list) that is an > MD5 of your primary key. Use that as your "accessor" index from the

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread Steve Midgley
ly people here). This will supplement your sparse index by detecting people who are scanning your sparse index space and generating lots of "misses." Hope that helps, Steve -- 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] Counting days ...

2008-03-14 Thread Steve Crawford
Aarni Ruuhimäki wrote: Thanks Steve, I'm not sure if I quite grasped this. It gives a bit funny results: SELECT sum ((date_smaller(res_end_day, '2007-12-31'::date) - date_larger(res_start_day, '2006-12-31'::date)) * group_size) AS days_in_period, c.country_name AS

Re: [SQL] Counting days ...

2008-03-13 Thread Steve Crawford
p_size ) Basically remove the "+1" so we don't include both start and end dates but move the start base back one day so anyone starting prior to Feb 1 gets the extra day added. Cheers, Steve -- 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] Counting days ...

2008-03-13 Thread Steve Crawford
+ 1) * group_size ) as person_days group by country_id; Add where-clauses to either for efficiency. Cheers, Steve -- 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] works but ...

2008-03-10 Thread Steve Midgley
speaking there is one sequence per primary key, by default on each table. So if you reset that key, then your table will start issuing keys at that new number. Another way to be more safe is to "+5" your sequence, so that even if a few inserts slip in, you're still ahead of the g

  1   2   >