Re: [SQL] SQL question....

2008-05-21 Thread Karl Denninger
Steve Midgley wrote: At 12:20 PM 5/21/2008, [EMAIL PROTECTED] wrote: Date: Wed, 21 May 2008 06:39:11 -0500 From: Karl Denninger <[EMAIL PROTECTED]> To: Gurjeet Singh <[EMAIL PROTECTED]> Cc: pgsql-sql@postgresql.org Subject: Re: SQL question Message-ID: <[EMAIL PROTECTED]> > Also, if you do

Re: [SQL] SQL question....

2008-05-21 Thread Steve Midgley
At 12:20 PM 5/21/2008, [EMAIL PROTECTED] wrote: Date: Wed, 21 May 2008 06:39:11 -0500 From: Karl Denninger <[EMAIL PROTECTED]> To: Gurjeet Singh <[EMAIL PROTECTED]> Cc: pgsql-sql@postgresql.org Subject: Re: SQL question Message-ID: <[EMAIL PROTECTED]> > Also, if you don't have it already, yo

Re: [SQL] SQL question....

2008-05-21 Thread Karl Denninger
Gurjeet Singh wrote: On Wed, May 21, 2008 at 8:33 AM, Karl Denninger <[EMAIL PROTECTED] > wrote: Gurjeet Singh wrote: On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED] > wrote: Gurjeet Singh wrote:

Re: [SQL] SQL question....

2008-05-21 Thread Gurjeet Singh
On Wed, May 21, 2008 at 8:33 AM, Karl Denninger <[EMAIL PROTECTED]> wrote: > Gurjeet Singh wrote: > > On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED]> > wrote: > >> Gurjeet Singh wrote: >> >>> On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]>> [EMAIL PROTECTE

Re: [SQL] SQL question....

2008-05-20 Thread Karl Denninger
Gurjeet Singh wrote: On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED] > wrote: Gurjeet Singh wrote: On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]

Re: [SQL] SQL question....

2008-05-20 Thread Gurjeet Singh
On Wed, May 21, 2008 at 4:47 AM, Karl Denninger <[EMAIL PROTECTED]> wrote: > Gurjeet Singh wrote: > >> On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote: >> >> assuming the following schema: >> >>create table access (name text, address ip) >

Re: [SQL] SQL question....

2008-05-20 Thread Karl Denninger
Gurjeet Singh wrote: On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED] > wrote: assuming the following schema: create table access (name text, address ip) I want to construct a SELECT statement which will return ONLY tuples cont

Re: [SQL] SQL question....

2008-05-20 Thread Gurjeet Singh
On Tue, May 20, 2008 at 11:44 PM, Karl Denninger <[EMAIL PROTECTED]> wrote: > assuming the following schema: > > create table access (name text, address ip) > > I want to construct a SELECT statement which will return ONLY tuples > containing IP and name pairs IF there is an IP that has two o

Re: [SQL] SQL question....

2008-05-20 Thread Harold A. Giménez Ch.
I think this is what you're looking for: SELECT * FROM access WHERE ip IN(SELECT ip FROM access GROUP BY ip HAVING count(*) > 1) On Tue, May 20, 2008 at 3:17 PM, Karl Denninger <[EMAIL PROTECTED]> wrote: > chester c young wrote: > > create table access (name text, address ip) > > I

Re: [SQL] SQL question....

2008-05-20 Thread Karl Denninger
chester c young wrote: create table access (name text, address ip) I want to construct a SELECT statement which will return ONLY tuples containing IP and name pairs IF there is an IP that has two or more NAMEs associated with it. many ways: select a1.* from access a1 where exists(

Re: [SQL] SQL question....

2008-05-20 Thread chester c young
> create table access (name text, address ip) > > I want to construct a SELECT statement which will return ONLY tuples > containing IP and name pairs IF there is an IP that has two or more > NAMEs associated with it. > > many ways: select a1.* from access a1 where exists( select 1 from ac

[SQL] SQL question....

2008-05-20 Thread Karl Denninger
assuming the following schema: create table access (name text, address ip) I want to construct a SELECT statement which will return ONLY tuples containing IP and name pairs IF there is an IP that has two or more NAMEs associated with it. I've not figured out how to do this; I can get a

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-14 Thread Marc Mamin
order by date desc,name regards, Marc Mamin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Jenkins Sent: Saturday, January 12, 2008 1:10 AM To: pgsql-sql@postgresql.org Subject: [SQL] SQL question: Highest column value of unique column pai

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-12 Thread Shane Ambler
Kevin Jenkins wrote: Thanks! How would I find the highest score in the union of the two tables? I tried this but it can't find unionTable: SELECT * FROM (select fnam1 as fname,lname1 as lname, score1 as score from myscorestable union select fnam2 as fname,lname2 as lname, score2 as score from m

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-11 Thread Kevin Jenkins
Thanks! How would I find the highest score in the union of the two tables? I tried this but it can't find unionTable: SELECT * FROM (select fnam1 as fname,lname1 as lname, score1 as score from myscorestable union select fnam2 as fname,lname2 as lname, score2 as score from myscorestable) as union

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-11 Thread Shane Ambler
Kevin Jenkins wrote: Hi, I have the following table which holds the result of 1 on 1 matches: FName1, LName1, Score1, FName2, LName2, Score2, Date John, Doe,85 Bill, Gates, 20 Jan 1. John, Archer, 90 John, Doe,120 Jan 5 Bob,Barker, 70 Calvin, Klien

[SQL] SQL question: Highest column value of unique column pairs

2008-01-11 Thread Kevin Jenkins
Hi, I have the following table which holds the result of 1 on 1 matches: FName1, LName1, Score1, FName2, LName2, Score2, Date John, Doe,85 Bill, Gates, 20 Jan 1. John, Archer, 90 John, Doe,120 Jan 5 Bob,Barker, 70 Calvin, Klien 8 Jan 8 John,

Re: [SQL] SQL Question

2004-11-21 Thread Mischa Sandberg
Igor Kryltsov wrote: We have table create table group_facility ( group_id integer not null, facility_id integer not null ) It stores facilities membership in group. For example: "North Region" - facilityA, facilityB I need to extract groups from this table which contain facilityN AND facilityZ and

[SQL] SQL Question

2004-11-21 Thread Igor Kryltsov
Hi, If anybody can offer better SQL query please. We have table create table group_facility ( group_id integer not null, facility_id integer not null ) It stores facilities membership in group. For example: "North Region" - facilityA, facilityB I need to extract groups from this table which conta

[SQL] sql question regarding count(*)

2003-03-06 Thread Rajesh Kumar Mallah
When does count(*) returns "o rows" ? and when does it return 1 row value being 0. tradein_clients=# SELECT count(*) from public.eyp_listing where sno> 0 and amount> 0 group by sno,branch,edition having count(distinct userid) > 1 ; count --- (0 rows) tradein_clients=# tradein_clients=#

[SQL] sql question after upgrade

2003-02-22 Thread James Cooper
Hi just upgraded to 7.3.2 and imported my db schema with no probs! Just wondering... why VOLATILE is being appended to my functions - can anyone ansewer me what this means? - should i be using joins instead, does this make a difference? If so an example of this would be much appreciated!! C

Re: [SQL] sql question:

2002-07-15 Thread Ahti Legonkov
Chris Aiello wrote: > hi all: > > I'm trying to figure out SQL to do the following: > I have an application that tracks SQL that is being sent to the database, > and one of it's features is the ability to identify whether a query is an > insert, update, delete, select, select with all rows return

[SQL] sql question:

2002-07-15 Thread Chris Aiello
hi all: I'm trying to figure out SQL to do the following: I have an application that tracks SQL that is being sent to the database, and one of it's features is the ability to identify whether a query is an insert, update, delete, select, select with all rows returned, the query is the first in a

RE: [SQL] SQL question

2001-07-10 Thread Robby Slaughter
D]]On Behalf Of Deepali Agarwal Sent: Friday, July 06, 2001 12:53 PM To: '[EMAIL PROTECTED]' Subject: [SQL] SQL question hello, I have a simple question about nested SQL statements. I remember having learnt of another way of writing nested SQL statements, using Joins I guess

Re: [SQL] SQL question

2001-07-10 Thread Josh Berkus
Deepali, >I have a simple question about nested SQL statements. I > remember > having learnt of another way of writing nested SQL statements, using > Joins I > guess. ... I'm afraid that your question is much to general to be answered. Frankly, I'm not sure what you mean by "

[SQL] SQL question

2001-07-10 Thread Deepali Agarwal
hello, I have a simple question about nested SQL statements. I remember having learnt of another way of writing nested SQL statements, using Joins I guess. I'm buildingh an ASP/ADO application or which using nested select becomes too complicated. Could you please throw some light ( pr

[SQL] SQL question

2001-02-06 Thread Alain Lavigne
I'm trying to extract references (relationships) between tables for the purpose of reverse/forward engineer from a modeling tool called PowerDesigner. Here is the sql: select u.usename, p.relname, v.usename, c.relname, t.tgconstrname, dumpref(t.tgargs, 4), **

[SQL] SQL question

2001-01-14 Thread Alain Lavigne
I'm trying to extract references (relationships) between tables for the purpose of reverse/forward engineer from a modeling tool called PowerDesigner. Here is the sql: select u.usename, p.relname, v.usename, c.relname, t.tgconstrname, dumpref(t.tgargs, 4),

[SQL] SQL question regarding a couple of table joins.

2000-11-06 Thread Warren Vanichuk
Greetings. We three have three tables, a links table which stores basic information about a link, a linksdetail table which stores more detailed information about the link, and a linkdaystats table which records the daily statistical information on the link. My problem is, once a day I want to

Antw: [SQL] SQL Question

2000-08-02 Thread Gerhard Dieringer
>>> Daryl Herzmann <[EMAIL PROTECTED]> 01.08.2000 22.38 Uhr >>> > Hello, > I hope this question is not too novice for this group. > > I have a table > > portfolio=# \d questions > Table "questions" > Attribute |Type | Modifier

[SQL] SQL Question

2000-08-01 Thread Daryl Herzmann
Hello, I hope this question is not too novice for this group. I have a table portfolio=# \d questions Table "questions" Attribute |Type | Modifier ---+-+---

Re: [SQL] SQL question

2000-07-17 Thread Tom Lane
Thomas Lockhart <[EMAIL PROTECTED]> writes: >> The immediate cause of this gripe was discussed just a day or so ago >> on one or another of the pgsql lists. The timestamp-to-date conversion >> routine has this weird idea that it should kick out an error instead >> of returning NULL when presented

Re: [SQL] SQL question

2000-07-17 Thread Tom Lane
Philip Warner <[EMAIL PROTECTED]> writes: > At 02:26 17/07/00 -0400, Tom Lane wrote: >> Well before my time, I guess --- as long as I've been paying attention, >> the function manager's approach was to call the routine first and *then* >> insert a NULL result ... if the routine hadn't crashed firs

Re: [SQL] SQL question

2000-07-16 Thread Philip Warner
At 02:26 17/07/00 -0400, Tom Lane wrote: > >Well before my time, I guess --- as long as I've been paying attention, >the function manager's approach was to call the routine first and *then* >insert a NULL result ... if the routine hadn't crashed first. That's >about as braindead a choice as I can

Re: [SQL] SQL question

2000-07-16 Thread Thomas Lockhart
> The immediate cause of this gripe was discussed just a day or so ago > on one or another of the pgsql lists. The timestamp-to-date conversion > routine has this weird idea that it should kick out an error instead > of returning NULL when presented with a NULL timestamp. That's a bug > IMHO, an

Re: [SQL] SQL question

2000-07-16 Thread Tom Lane
Philip Warner <[EMAIL PROTECTED]> writes: > Another alternative would be to define a 'coalesce' function (I don't think > PG has one), which takes an arbitrary number of arguments and returns the > first non-null one. We surely do have that! It even works pretty well in 7.0 ;-) (I think there we

Re: [SQL] SQL question

2000-07-16 Thread Philip Warner
At 13:41 17/07/00 +1000, Carolyn Lu Wong wrote: >> Try >> select count(*) from table1 where account_no = 1 and start_date_time is >> null; >> >> and see if you get 0. > >Yes, i get 0 from running the above query, but it fails if i re-arrange >the where clause to: > > select * from table

Re: [SQL] SQL question

2000-07-16 Thread Carolyn Lu Wong
Philip Warner wrote: > > At 12:07 17/07/00 +1000, Carolyn Lu Wong wrote: > >I have table with the following definition: > > > > create table table1( > > account_no int4, > > start_date_tme datetime > > > > ); > > > >The table may

Re: [SQL] SQL question

2000-07-16 Thread Philip Warner
At 12:07 17/07/00 +1000, Carolyn Lu Wong wrote: >I have table with the following definition: > > create table table1( > account_no int4, > start_date_tme datetime > > ); > >The table may contain null values for start_date_time. > >Wh

[SQL] SQL question

2000-07-16 Thread Carolyn Lu Wong
I have table with the following definition: create table table1( account_no int4, start_date_tme datetime ); The table may contain null values for start_date_time. When I run the following SQL query, it fails: s