[SQL] how to use recursion to find end nodes of a tree

2006-04-10 Thread mike
get 7,8,10. I have written recursive functions which return all nodes on a branch of a tree but I can't think of a way to return the end nodes does anyone know of a solution? Many thanks, Mike ---(end of broadcast)--- TIP 4: Have you searche

Re: [SQL] how to use recursion to find end nodes of a tree

2006-04-11 Thread mike
Thankyou very much Yasir and Ross for your help and advice. I have created a pl/pgsql version of Yasirs algorithm which works perfectly, I am also looking into improving efficiency by flaging leaf records. Here is my pl/pgsql solution in case it helps anyone out: CREATE OR REPLACE FUNCTION paren

Re: [SQL] The best option to insert data with primary id

2010-12-06 Thread mike
table')), ...) RETURNING (SELECT currval ('seq_table')) AS id Much simplier: INSERT INTO table (name, email, salary) VALUES ('joe', 'j...@example.com', 100) RETURNING id; Cheers, -Mike -- Michał Roszka m...@if-then-else.pl -- Sent via pgsql-sql mailing

Re: [SQL] The best option to insert data with primary id

2010-12-06 Thread mike
ake a nextval of the sequence and update the id accordingly once the record *has been actually inserted* instead of poking the sequence each time you *are going to insert* something. I am pretty sure, that the table is locked to prevent inserts until the after-insert-trigger is finished. Cheers,

[SQL] lo_export and files permissions

2000-08-16 Thread mike . baroukh
De: Mike Baroukh <[EMAIL PROTECTED]> À: <[EMAIL PROTECTED]> Objet: lo_export and files permissions Date : lundi 14 août 2000 10:44 Hi everybody. Who can help me with a lo_export() problem ? : I'm using lo_export function in sql statement with pgsql 6.5 on Linux RH 6.2. Data

Re: [SQL] lo_export and files permissions

2000-08-16 Thread Mike Baroukh
"rm -f". But I can't delete using Java's File object. Mike - Original Message - From: Guo Bin <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, August 16, 2000 11:31 AM Subject: Re: [SQL] lo_export and files permissions

Re: [SQL] Trigger

2000-09-10 Thread Mike Baroukh
There is a sample in postgres documentation. (See below). the only problem is for using langage plpgsql. If it is not understand by your database, you must use command createlang plpgsql dbname as the owner of the database. CREATE TABLE emp ( empname text, salary int4,

Re: [SQL] problems with postmaster

2000-11-24 Thread Mike Castle
ipcclean pg_ctl stop Though finding out about ipcclean was not easy considering the output given. There is no mention of it in any of the FAQs. mrc -- Mike Castle Life is like a clock: You can work constantly [EMAIL PROTECTED] and be right all the time, or not work at all

Re: [SQL] reinitialize a sequence?

2000-12-04 Thread Mike Castle
setval(); Sometimes it's good to read files in the source tree (such as HISTORY). mrc -- Mike Castle Life is like a clock: You can work constantly [EMAIL PROTECTED] and be right all the time, or not work at all www.netcom.com/~dalgoda/ and be right at least twice

Re: [SQL] plpgsql

2000-12-12 Thread Mike Castle
On Sat, Dec 09, 2000 at 08:16:06AM +, feblec wrote: > FUNCTION: 'plpgsql'. Recognized languages are sql, C, internal and the > created procedural languages. Look at: postgresql-7.0.3/src/pl/plpgsql/enable_plpgsql mrc -- Mike Castle Life is like a cloc

Re: [SQL] Invoice number

2000-12-21 Thread Mike Castle
On Thu, Dec 21, 2000 at 11:10:00AM +0100, Kaare Rasmussen wrote: > - Sequences are not rollback'able. Did you mean SERIAL instead of sequence here? If so, why is no rollbackable an issue? All you should need is unique numbers. Not necessarily exactly sequential numbers. mrc --

Re: [SQL] Create table doesn't work in plpgsql

2000-12-21 Thread Mike Castle
closer to Postgres, e.g. in plpgsql? Can this be done using tcl or perl? mrc -- Mike Castle Life is like a clock: You can work constantly [EMAIL PROTECTED] and be right all the time, or not work at all www.netcom.com/~dalgoda/ and be right at least twice a day. -- mrc We are all

Re: [SQL] Invoice number

2000-12-21 Thread Mike Castle
On Thu, Dec 21, 2000 at 05:50:43PM +, Oliver Elphick wrote: > Mike Castle wrote: > >On Thu, Dec 21, 2000 at 11:10:00AM +0100, Kaare Rasmussen wrote: > >> - Sequences are not rollback'able. > > > >Did you mean SERIAL instead of sequence here? > &

Re: [SQL] Using INDEX on date/time values // Re: how to select a time frame on timestamp rows.

2001-01-14 Thread Mike Castle
t; > select user_name from tbacct where extract(month from acct_timestamp) = 11 ... > > is there any way of using an index for selecting some rows, e.g. > selecting all data from one month? What about select blah from foo where month >= 2000-11-01 and month < 2000-12-01 Fix up as

Re: [SQL] Problem with Dates

2001-01-24 Thread Mike Castle
- 2001-12-31 00:00:00-08 (1 row) template1=> select '2000-12-31'::timestamp+'1 year'::timespan; ?column? 2001-12-31 00:00:00-08 (1 row) mrc -- Mike Castle Life is like a clock: You can work constantly [EMAIL PROTEC

[SQL] Re: Problem with Dates

2001-01-24 Thread Mike Castle
t '31/12/2000'::date; select '31/12/2000'::date + '365 days'::timespan; and 364, 363, etc. Not sure if gets you anywhere. But data points. There is an email archive on the postgresql.org website you could search if you think it's been answered before. mrc --

[SQL] Is there anything like DESCRIBE?

2001-01-25 Thread Mike D'Agosta
Hi, I have a number of empty tables and I want to get the column names and data types with an SQL statement. I want to do this procedurally, not interactively (so I can't use \d in psql). Postgres doesn't support DESCRIBE... is there any other way to do this? Thanks! Mike

[SQL] Re: Is there anything like DESCRIBE?

2001-01-26 Thread Mike D'Agosta
"\d " will give you information similar to what you would normally get from a DESCRIBE. Mike -- "Mike D'Agosta" <[EMAIL PROTECTED]> wrote in message 94n93j$2j6j

RE: [GENERAL] Date question

2001-03-06 Thread Mike Mascari
How about: SELECT '2001-03-06'::timestamp + '1 Year'; Hope that helps, Mike Mascari -Original Message- From: Boulat Khakimov [SMTP:[EMAIL PROTECTED]] Sent: Tuesday, March 06, 2001 2:20 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subj

Re: [SQL] Where are the 7.1 RPM's?

2001-04-17 Thread Mike Castle
On Tue, Apr 17, 2001 at 06:12:40PM -0700, clayton wrote: > if a spec file was made avail we could all make rpms! You too can ./configure ; make ; make install !! -- Mike Castle Life is like a clock: You can work constantly [EMAIL PROTECTED] and be right all the time, or

Re: [SQL] has anyone tried running in MAC OS X

2001-05-17 Thread Mike Castle
ding it yet? :-> mrc -- Mike Castle Life is like a clock: You can work constantly [EMAIL PROTECTED] and be right all the time, or not work at all www.netcom.com/~dalgoda/ and be right at least twice a day. -- mrc We are all of us living in the shadow of Manhattan

Re: [SQL] [GENERAL] arrays

2002-09-29 Thread Mike Sosteric
these may sound like terribily stupid questions. but we need some quick guidance before proceeding with a schema that relies on these advanced data features of postgres tia mike ___ This communication is intended for the use of the recipient to whom it is addressed, and may contain

Re: [SQL] [GENERAL] arrays

2002-09-30 Thread Mike Sosteric
On Mon, 30 Sep 2002, Bruno Wolff III wrote: > > 3) can you do selects on only a portion of a multidimensional array. That > > is, if you were storing multilanguage titles in a two dimensional array, > > > > [en], "english title" > > [fr], "french title" > > > > could you select where title[0]

Re: [SQL] [GENERAL] arrays

2002-09-30 Thread Mike Sosteric
ike Cache'). > > Good luck. > > -Josh Berkus > > > > Mike Sosteric <[EMAIL PROTECTED]> Managing Editor, EJS <http://www.sociology.org/> Department of Global and Social Analysis Executive Director, ICAAP <http://www.icaap.org/> Athabasca Un

Re: [SQL] [GENERAL] arrays

2002-09-30 Thread Mike Sosteric
On Mon, 30 Sep 2002, Josh Berkus wrote: thanks for this. we will stick with the relational model. m > > Mike, > > > I have a very good sense of the strengths of relational databases. But > > they are also limited when it comes to object orientaed data (like XML > >

Re: [SQL] [GENERAL] arrays

2002-09-30 Thread Mike Sosteric
any ideas? m > > Mike, > > > thanks for this. we will stick with the relational model. > > Hey, don't make your decision entirely based on my advice.Do some > research! I'm just responding "off the cuff" to your questions. > > If you do

Re: [SQL] [GENERAL] arrays

2002-09-30 Thread Mike Sosteric
t; > > ---(end of broadcast)--- > TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED] > Mike Sosteric <[EMAIL PROTECTED]> Managing Editor, EJS <http://www.sociology.org/> Department of Global and Soc

Re: [SQL] [pgadmin-support] hi

2002-10-18 Thread Hepworth, Mike
e.   Later,   Mike Hepworth.. -Original Message-From: lz John [mailto:[EMAIL PROTECTED]]Sent: Thursday, October 17, 2002 1:07 AMTo: [EMAIL PROTECTED]Cc: [EMAIL PROTECTED]Subject: [pgadmin-support] hi i don't send mail to [EMAIL PROTECTED],but i need help how to m

[SQL] Question about slow Select when using 'IN'.

2002-12-02 Thread Mike Winter
Hi all, I hope someone can help me out. I'm doing single-table select statements on a large table and I could use some help in speeding it up. My query is of the form: SELECT col, count(col) FROM tab WHERE id IN (3, 4,7,2, ...) GROUP BY COL ORDER BY count for a very large number of rows. I have

[SQL] Large Query Question. (Slow Select while using 'IN')

2002-12-03 Thread Mike Winter
Hi all, I hope someone can help me out. I'm doing single-table select statements on a large table and I could use some help in speeding it up. My query is of the form: SELECT col, count(col) FROM tab WHERE id IN (3, 4,7,2, ...) GROUP BY COL ORDER BY count for a very large number of rows. I have

[SQL] Ran out of connections

2002-12-04 Thread Mike Diehl
ole LOT of postgres processes running, idle. BTW, one of the postgres processes was doing a vacuum analyze. I'm running 7.2. Can anyone tell me how to fix this? The out put of the ps command can be seen at http://dominion.dyndns.org/~mdiehl/ps.txt Thanx in advance, -- Mike Diehl Network Tool

Re: [SQL] Ran out of connections

2002-12-04 Thread Mike Diehl
On Wednesday 04 December 2002 03:25 pm, Roberto Mello wrote: > On Wed, Dec 04, 2002 at 03:08:35PM -0700, Mike Diehl wrote: > > Can anyone tell me how to fix this? The out put of the ps command > > can be seen at http://dominion.dyndns.org/~mdiehl/ps.txt >

[SQL] SCHEMA's

2003-03-03 Thread Hepworth, Mike
r schema b. Any ideas? Thanks, Mike Hepworth. ---(end of broadcast)--- TIP 3: 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

[SQL] Rule for updating through a view.

2003-03-21 Thread Mike Meyer
Ok, I found the documentation on using views to udpate the underlying database. But I can't seem to get my head around making it actually work, because updates may change only a few columns, and the columns in my views come from multiple tables. Could someone provide an example (CC'ing me, please,

[SQL] casting to arrays

2003-07-18 Thread Mike Rylander
! -- Mike Rylander ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] casting to arrays

2003-07-18 Thread Mike Rylander
Thank you! This is great news. Is there a projected release date for 7.4? Also, is there a published roadmap, or should I just get on the developers list? Thanks again. --- Mike Rylander On Friday 18 July 2003 05:34 pm, Joe Conway wrote: > Mike Rylander wrote: > > I have a rather

Re: [SQL] converting interval to timestamp

2003-08-01 Thread Mike Rylander
> > Also does anyone know what field type an interval would map to in jdbc? > > thanks > > > > ---(end of broadcast)--- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining colu

[SQL] "SELECT IN" Still Broken in 7.4b

2003-08-20 Thread Mike Winter
I'm sure many on this list are sick of hearing about this problem, but it was on the fix list for 7.4, but doesn't appear to have been changed. You can see one of the many threads on the problem at: http://archives.postgresql.org/pgsql-sql/2003-05/msg00352.php Basically, queries of the form SELEC

Re: [SQL] "SELECT IN" Still Broken in 7.4b

2003-08-20 Thread Mike Winter
On Wed, 20 Aug 2003, Stephan Szabo wrote: > > On Wed, 20 Aug 2003, Mike Winter wrote: > > > I'm sure many on this list are sick of hearing about this problem, but it > > was on the fix list for 7.4, but doesn't appear to have been changed. > > IN (subselect)

Re: [SQL] "SELECT IN" Still Broken in 7.4b

2003-08-20 Thread Mike Winter
On Wed, 20 Aug 2003, Rod Taylor wrote: > Ensure your IN list is unique. You might find better times by through > an indexed temp table. That is what I ended up doing, but it's not a very elegant solution. MySQL does queries of this type orders of magnitudes faster than Postgres on large value li

Re: [SQL] new max function

2003-10-17 Thread Mike Rylander
igo! > > ---(end of broadcast)--- > TIP 3: 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 clean

[SQL] How Do I Toggle Quoted Identifiers?

2003-12-04 Thread Google Mike
I'm on PHP 4.2.2 and RedHat 9 with PGSQL. I want to turn quoted identifiers off with my SQL queries. What SQL statement or .CONF setting do I need to change so that I can turn quoted identifiers off? Quoted identifiers, as I understand them, are where you must put double quotes around any table or

Re: [SQL] Dramatic slowdown of sql when placed in a function

2004-03-09 Thread Mike Moran
Jeff Boes <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > At some point in time, [EMAIL PROTECTED] (Mike Moran) wrote: > > >Hi. I currently have a fairly large query which I have been optimizing > >for later use in a function. There are things in

Re: [SQL] How do i extract a certain bit from a bigint column

2004-05-12 Thread Mike Rylander
On Wednesday 12 May 2004 07:05 am, Mats Sjöberg wrote: > Hello everyone > In a table i have a column status of type bigint. > I need to create a view of the table including all rows with bit 4 set > (value 8). > At the same time i need to exclude excludig all rows with bit 2 set. > > What is the sy

Re: [SQL] [HACKERS] MERGE-esque Functionallity (was: Adding MERGE to the TODO list (resend with subject))

2004-05-14 Thread Mike Rylander
On Tuesday 11 May 2004 09:44 am, Bruce Momjian wrote: [snip] > > > > Bruce Momjian kirjutas E, 10.05.2004 kell 06:58: > > > > > Added to TODO: > > > > > > > > > > * Add MERGE command that does UPDATE, or on failure, INSERT > > > > [snip] Hello all. I have been lurking here for a bit and the

Re: [SQL] Trigger problem

2004-06-09 Thread Mike Rylander
kasper wrote: > Hi guys > > Im tryint to make a trigger that marks a tuble as changed whenever someone > has updated it > > my table looks something like this > > create table myTable ( > ... > changed boolean; > ) > > now ive been working on a trigger and a sp that looks like this, bu

Re: [SQL] How to filter on timestamps?

2004-07-09 Thread Mike Rylander
B.W.H. van Beest wrote: > > > I have a table where one of the columns is of type 'TIMESTAMP' > > How can I do a query to filter on the TIMESTAMP value, e.g. to obtain > all rows earlier than a certain time stamp? Think of the math opperators '<' and '>' as 'before' and 'after', respectively.

Re: [SQL] implementing an out-of-transaction trigger

2004-09-15 Thread Mike Rylander
>I've come across a situation where I'd like to use some kind of "out-of-transaction >trigger" to do some processing after changes to some tables, but without extending >the duration of the main transaction. Of course, it's important that the processing be >completed so it has to be, as far as poss

Re: [SQL] sql

2004-10-25 Thread Mike Rylander
On Mon, 25 Oct 2004 10:13:37 +0200, cristivoinicaru <[EMAIL PROTECTED]> wrote: > I have a postgres table like this: > > CREATE TABLE "temp50" ( > "gc" character varying(36), > "co" character varying(7), > "data" date, > "ora" smallint > > ); > > It contains the following records: > > 500370

Re: [SQL] sql

2004-10-25 Thread Mike Rylander
On Mon, 25 Oct 2004 05:44:06 -0600, Andrew J. Kopciuch <[EMAIL PROTECTED]> wrote: > On Monday 25 October 2004 05:20, Mike Rylander wrote: > > SELECT * FROM temp50 GROUP BY gc ORDER BY ora DESC; > > You can not have have expressions (columns etc.) in the SELECT list that

Re: [SQL] tree structure photo gallery date quiery

2004-11-16 Thread Mike Rylander
rom photos where id in ( > select p1.id from tree as p1, tree as p2 where p1.lft between p2.lft > and p2.rgt and p2.id = gallery_id > ); > return pcount; > end' language 'plpgsql'; > > > > -- > Gary Stainburn > > This email does not contain private or confidential material as it > may be snooped on by interested government parties for unknown > and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 > > ---(end of broadcast)--- > TIP 3: 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 > -- Mike Rylander [EMAIL PROTECTED] GPLS -- PINES Development Database Developer ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Recursive SETOF function

2004-11-22 Thread Mike Rylander
END LOOP; RETURN END;' LANGUAGE 'plpgsql'; Hope that helps! > -- > > ---(end of broadcast)--- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to [E

Re: [SQL] Recursive SETOF function

2004-11-22 Thread Mike Rylander
Forgot one line. See below On Mon, 22 Nov 2004 11:54:30 -0500, Mike Rylander <[EMAIL PROTECTED]> wrote: > I'm feeling sausey today, so here is my (untested) attempt to [snip] > > CREATE FUNCTION svp_getparentproviderids (@child_provider INTEGER) > > RETURNS @provid

Re: [postgres] Re: [SQL] Recursive SETOF function

2004-11-22 Thread Mike Rylander
t; CREATE FUNCTION > sp_demo_505=# select * from svp_getparentproviderids(21112); > ERROR: incorrect argument to RETURN NEXT at or near "cid" > CONTEXT: compile of PL/pgSQL function "svp_getparentproviderids" near > line 13 > > -- Mike Rylander [EMAIL PROTECTED] GPLS -- PINES Development Database Developer ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Breadth first traversal in PLSQL (How to implement Queue?)

2004-12-15 Thread Mike Rylander
On Wed, 15 Dec 2004 12:54:44 -0600, Richard Rowell <[EMAIL PROTECTED]> wrote: > I have a table with a unary (recursive) relationship that represents a > hierarchy. With the gracious help of Mike Rylander I was able to port a > TSQL function that would traverse "up" the hi

Re: [SQL] Breadth first traversal in PLSQL (How to implement Queue?)

2004-12-15 Thread Mike Rylander
Arg! One more change below On Wed, 15 Dec 2004 21:48:57 -0500, Mike Rylander <[EMAIL PROTECTED]> wrote: > On Wed, 15 Dec 2004 12:54:44 -0600, Richard Rowell > <[EMAIL PROTECTED]> wrote: > > I have a table with a unary (recursive) relationship that represents a > >

Re: [SQL] Constraint on 2 column possible?

2005-01-27 Thread Mike Rylander
nt4 NOT NULL references contact(id), > id_wk int4 NOT NULL references contact(id) > ); > but how do I check also the type column? > > Best regards, > Andy. -- Mike Rylander [EMAIL PROTECTED] GPLS -- PINES Development Database Developer http://open-ils.org -- Mike Rylande

Re: [SQL] Serial and Index

2005-02-27 Thread Mike Rylander
istgreSQL manual. Is > this true? Thanks. The FAQ entry is incorrect. If you make your SERIAL column the PRIMARY KEY of the table, however, a UNIQUE index will be created. -- Mike Rylander [EMAIL PROTECTED] GPLS -- PINES Development Database Developer http://open-ils.org -

Re: [SQL] detaching triggers

2005-03-27 Thread Mike Rylander
-createrule.html Hope that helps! -- Mike Rylander [EMAIL PROTECTED] GPLS -- PINES Development Database Developer http://open-ils.org ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] gone blind - can't see syntax error

2005-04-01 Thread Mike Rylander
e_id = de.de_id, > left outer join customers c on r.r_c_id = c.c_id, > left outer join comment_tallies co on r.r_id = co.r_id > ORDER BY r.r_id; > psql:new-view.sql:19: ERROR: parser: parse error at or near "left" Don't put commas between your joins. -- Mike Rylan

Re: [SQL] Speed up slow select - was gone blind

2005-04-01 Thread Mike Rylander
> > This email does not contain private or confidential material as it > may be snooped on by interested government parties for unknown > and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 > > ---(end of broadcast)--

Re: [SQL] ENUM like data type

2005-06-28 Thread Mike Rylander
't create a generic type to handle this, you can create a DOMAIN to wrap up your constraint for each "enum" type field that you want: CREATE DOMAIN fruit AS TEXT CHECK (VALUE IN ('apple','orange','banana')); CREATE TABLE eat ( food fruit ); http://ww

Re: [DOCS] [SQL] Update timestamp on update

2005-10-13 Thread Mike Diehl
there suggesting you go look at > > the PL languages first, but obviously it's not getting the job done. > > Chapter 35 is plpgsql.. do you mean chapter 32.4? > > > Anybody have a better idea? > > What about a See Also section ala man pages that links to

[SQL] Question about functions

2005-10-16 Thread Mike Plemmons
tblStuff WHERE ides LIKE '%$1%' LOOP RETURN NEXT myrec; END LOOP; RETURN; END; $$ LANGUAGE 'plpgsql'; Thanks so much for any insight you can give me!!! Mike

Re: [SQL] simple? query

2009-08-13 Thread Relyea, Mike
st (registered) values ('1'); > else > insert into test (registered) values ('0'); > end if; Perhaps UPDATE is what you're looking for? http://www.postgresql.org/docs/8.4/static/sql-update.html UPDATE test SET registered = '1' WHERE uid = 'janvleuven1

Re: [SQL] simple? query

2009-08-14 Thread Relyea, Mike
> From: Relyea, Mike [mailto:mike.rel...@xerox.com] > Sent: Thursday, August 13, 2009 10:47 PM > > > From: pgsql-sql-ow...@postgresql.org > [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Jan Verheyden > > Subject: [SQL] simple? query > > > > Hi, > &g

Re: [SQL] simple? query

2009-08-14 Thread Relyea, Mike
> From: Jan Verheyden [mailto:jan.verhey...@uz.kuleuven.ac.be] > Sent: Friday, August 14, 2009 9:03 AM > To: Relyea, Mike > Subject: RE: [SQL] simple? query > > The goal is, where uid not equals to 'janvleuven10' a new > record should be inserted with the uid

[SQL] Aggregating results across multiple partitions

2011-08-02 Thread Mike O'Connel
Hi I see that some queries are not Order(n) where n=number of partitions. However, if one were to run the query separately against different partitions and aggregate the results it could be Order(n). Can such an approach be implemented in a more generic manner in pgsql? Thanks Mike

[SQL] Lowest 2 items per

2012-06-01 Thread Relyea, Mike
yield Is Not Null GROUP BY printers.make, printers.model, consumables.color, consumables.type ORDER BY make, model; After doing a google search I didn't come up with anything that I was able to use so I'm asking you fine folks! Mike -- Sent via pgsql-sql mailing list (pgsql-sql@postgres

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Relyea, Mike
> -Original Message- > From: David Johnston [mailto:pol...@yahoo.com] > Sent: Friday, June 01, 2012 11:13 AM > To: Relyea, Mike > Cc: > Subject: Re: [SQL] Lowest 2 items per > > > I would recommend using the "RANK" window function with an appropri

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Relyea, Mike
> -Original Message- > From: Oliveiros d'Azevedo Cristina [mailto:oliveiros.crist...@marktest.pt] > Sent: Friday, June 01, 2012 11:21 AM > To: Oliveiros d'Azevedo Cristina; Relyea, Mike; pgsql-sql@postgresql.org > Subject: Re: [SQL] Lowest 2 items per > >

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Relyea, Mike
> -Original Message- > From: Oliveiros d'Azevedo Cristina [mailto:oliveiros.crist...@marktest.pt] > Sent: Friday, June 01, 2012 12:28 PM > To: Relyea, Mike > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] Lowest 2 items per > > Yes, you are right, now, thin

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Relyea, Mike
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Mario Dankoor > Sent: Friday, June 01, 2012 2:31 PM > To: Relyea, Mike > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] Lowest 2 items per > Mike,

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Relyea, Mike
> -Original Message- > From: Oliveiros d'Azevedo Cristina [mailto:oliveiros.crist...@marktest.pt] > Sent: Friday, June 01, 2012 12:59 PM > To: Relyea, Mike > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] Lowest 2 items per > > * I see... > >

Re: [SQL] Summing & Grouping in a Hierarchical Structure

2013-02-18 Thread Relyea, Mike
used a pivot table in Microsoft Excel. Not sure what your environment or requirements are but pivot tables are widely used in business, easy to share, can be formatted, and give the user the ability to drill down and navigate to the data they want to see. I'd set up a query to pull the

[SQL] Problem with phone list.

2007-08-15 Thread Mike Diehl
s in it but the unique id is unique. I need to get a list of distinct phone numbers and the coorisponding largest call duration. I've got the idea that this should be a self-join on phone number where a.id<>b.id, but I just can't seem to get the max duration. A

Re: [SQL] Problem with phone list.

2007-08-15 Thread Mike Diehl
Yup, that did it. I don't know why I made it harder than it had to be. Thank you. Mike. On Wednesday 15 August 2007 02:58:22 pm Fernando Hevia wrote: > Try this: > > Select * > from view v1 > where duration = (select max(duration) from view v2 where v2.phone_number = > v

[SQL] Refactored queries needing validation of syntactic equivalence

2007-10-10 Thread Mike Adams
Hello! I'm a long time lurker who has become responsible for maintaining / updating utility queries at work. I've reworked two queries (as text attachment as they are wide lines) to enhance the planner's chance of speeding up the queries (Oracle8i's). I'm looking for someone to eyeball them a

Re: [SQL] Refactored queries needing validation of syntactic equivalence

2007-10-13 Thread Mike Adams
Richard Huxton wrote: (quoted OP lines edited for brevity...) Mike Adams wrote: ... I've reworked two queries (as text attachment as they are wide lines) to enhance the planner's chance of speeding up the queries (Oracle8i's). Well, I can't say it's standard pr

Re: [SQL] Refactored queries needing validation of syntactic equivalence

2007-10-20 Thread Mike Adams
Richard Huxton wrote: Mike Adams wrote: So. The first query should pull all 'MOM' records that have one or more corresponding, and possibly orphaned, unassigned receiving records belonging to the same po_cd and item_cd. The second query should pull all unassigned, and possibl

[SQL] Case Insensitive searches

2008-08-04 Thread Mike Gould
In the application that we are working on, all data searches must be case insensitive. Select * from test where column1 = 'a' and Select * from test where column1 = 'A' should always be the same and use the index if column1 is indexed. In order to do this am I going to be required to us

Re: [SQL] order function in aggregate

2008-08-20 Thread Mike Toews
Richard Huxton wrote: Michael Toews wrote: You could accumulate the values in an array and then sort that with the final-func that create aggregate supports. Thanks for the help. Here was my final functions to aggregate things into a comma serpented text element (if anyone is interested):

[SQL] Multi-line text fields

2008-09-22 Thread Mike Toews
im to the first line only (the normal trim function doesn't appear to do this) Thanks in advance. -Mike -- 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 number in a result

2008-10-09 Thread Relyea, Mike
> Is there a function or special system label I can use that would generate a sequence number in the returning result set? Would something like this work for you? CREATE TEMP SEQUENCE foo; SELECT a, b, c, nextval('foo') AS order FROM t1 ORDER BY a; Mike Relyea Product Develop

[SQL] Re: [GENERAL] TOP SESSIONS?

2000-05-31 Thread Mike Mascari
nd when processing a SQL statement, much like sendmail. You should be able to determine who's connected and what they're doing with something like: ps axf You'll see who's connected to what database from what machine and the type of query being executed. I don't know