Re: [SQL] Unions and Grouping

2006-12-15 Thread Aaron Bono
On 12/15/06, Ragnar <[EMAIL PROTECTED]> wrote: On fös, 2006-12-15 at 16:17 -0600, Aaron Bono wrote: > On 12/15/06, Tom Lane <[EMAIL PROTECTED]> wrote: > "Aaron Bono" <[EMAIL PROTECTED]> writes: > > My question, what do the SQL Specifications say should > happen on a Union

Re: [SQL] Unions and Grouping

2006-12-15 Thread Ragnar
On fös, 2006-12-15 at 16:17 -0600, Aaron Bono wrote: > On 12/15/06, Tom Lane <[EMAIL PROTECTED]> wrote: > "Aaron Bono" <[EMAIL PROTECTED]> writes: > > My question, what do the SQL Specifications say should > happen on a Union? > > Is it supposed to eliminate duplicat

Re: [SQL] Unions and Grouping

2006-12-15 Thread Aaron Bono
On 12/15/06, Tom Lane <[EMAIL PROTECTED]> wrote: "Aaron Bono" <[EMAIL PROTECTED]> writes: > My question, what do the SQL Specifications say should happen on a Union? > Is it supposed to eliminate duplicates even WITHIN the individual queries > that are being unioned? Yes. SQL92 7.10 saith:

Re: [SQL] Unions and Grouping

2006-12-15 Thread Tom Lane
"Aaron Bono" <[EMAIL PROTECTED]> writes: > My question, what do the SQL Specifications say should happen on a Union? > Is it supposed to eliminate duplicates even WITHIN the individual queries > that are being unioned? Yes. SQL92 7.10 saith: b) If a set operator is specified, then th

[SQL] Unions and Grouping

2006-12-15 Thread Aaron Bono
I have a question about the SQL Specifications in regards to Unions... I recently put together a query that involved unions similar to the following: SELECT 'Query 1' as id, my_value FROM my_view UNION SELECT 'Query 2' as id, my_value FROM my_other_view ; The first query in the unio

Re: [SQL] join and sort on 'best match'

2006-12-15 Thread Ragnar
On fös, 2006-12-15 at 22:10 +0530, Ashish Ahlawat wrote: > > > Hi team > > I was just asking that If table ITEM3 has all the columns then why we > need to have a join ?? even we put a sorting very easily. > On 12/14/06, Markus Schaber <[EMAIL PROTECTED]> wrote: > Hi, Ashish, >

Re: [SQL] join and sort on 'best match'

2006-12-15 Thread Ashish Ahlawat
Hi team I was just asking that If table ITEM3 has all the columns then why we need to have a join ?? even we put a sorting very easily. *** Any way I have a very intersting question to all of you. I want to fetch more that 70,000 BLOB from different customer servers. the issue is there are som

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Richard Broersma Jr
> not bad, except you miss the initial state for each cid, > and I do not see how you get the final duration. > cid | duration | state > -+--+--- > 101 |2 | 1 > 101 |2 | 2 > 101 |3 | 1 > 101 |3 | 2 > 102 |2 | 1 > 10

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Ragnar
On fös, 2006-12-15 at 06:01 -0800, Richard Broersma Jr wrote: > > CIDATIME STATE > > 10112/10/2006 1 > > 10112/12/2006 2 > > 10112/14/2006 1 > > 10112/17/2006 2 > > 10212/14/2006 1 > > 10212/16/2006 2 > > 102

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Richard Broersma Jr
> CIDATIME STATE > 10112/10/2006 1 > 10112/12/2006 2 > 10112/14/2006 1 > 10112/17/2006 2 > 10212/14/2006 1 > 10212/16/2006 2 > 10212/18/2006 3 select A.cid, (A.atime - max(B.atime)) duration, A.sta

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Ragnar
On fös, 2006-12-15 at 19:21 +0600, Partha Guha Roy wrote: > Thanks for everyones email. Let me clarify a little bit more. > > Actually there is a state change of an entity. now the results are > stored in the following manner: > > CIDATIME STATE > 10112/10/2006 1 >

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Partha Guha Roy
Hi, Thanks for everyones email. Let me clarify a little bit more. Actually there is a state change of an entity. now the results are stored in the following manner: CIDATIME STATE 10112/10/2006 1 10112/12/2006 2 10112/14/2006 1 10112/

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Richard Broersma Jr
> > ID ATIME (MM/dd/) > == > 110/12/2006 > 210/14/2006 > 310/18/2006 > 410/22/2006 > 510/30/2006 > > Now I need a query that will subtract atime of row 1 from row 2, row2 from > row3 and so on... just an ide

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Marc Mamin
I see 3 solutions. A) self join B) define a procedure that return a set of records. this use only a single table scan on the ordered table not tested, just the genera idea: CREATE OR REPLACE FUNCTION foo() RETURNS SETOF AS ... DELARE previous_time int8; --(or whaever da

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Joe
On Fri, 2006-12-15 at 18:27 +0600, Partha Guha Roy wrote: > I have a table that contains data like this: > > ID ATIME (MM/dd/) > == > 110/12/2006 > 210/14/2006 > 310/18/2006 > 410/22/2006 > 510/30/2006 > > No

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Ragnar
On fös, 2006-12-15 at 18:27 +0600, Partha Guha Roy wrote: > Hi, > > I have a table that contains data like this: > > ID ATIME (MM/dd/) > == > 110/12/2006 > 210/14/2006 > 310/18/2006 > 410/22/2006 > 510/30/200

[SQL] Need to subtract values between previous and current row

2006-12-15 Thread Partha Guha Roy
Hi, I have a table that contains data like this: ID ATIME (MM/dd/) == 110/12/2006 210/14/2006 310/18/2006 410/22/2006 510/30/2006 Now I need a query that will subtract atime of row 1 from row 2, row2 from ro