Re: [SQL] complex query

2012-10-28 Thread Oliveiros d'Azevedo Cristina
Hi, Scott. I'd like to kick in this thread to ask you some advice, as you are experienced in optimizing queries. I also use extensively joins and unions (less than joins though). Anyway, my response times are somewhat behind miliseconds, they are situated on seconds range, and sometimes they ex

Re: [SQL] Disabling constraint check

2012-09-17 Thread Oliveiros d'Azevedo Cristina
Have you tried this ALTER TABLE table_name DROP CONSTRAINT constraint_name; Best, Oliveiros - Original Message - From: "Salomao Domingos" To: Sent: Monday, September 17, 2012 7:58 PM Subject: [SQL] Disabling constraint check Hi, I'm need to import data to PostgreS

Re: [SQL] generated dates from record dates - suggestions

2012-08-20 Thread Oliveiros d'Azevedo Cristina
With a CASE ... WHEN statement? Best, Oliver - Original Message - From: "Gary Stainburn" To: Sent: Monday, August 20, 2012 1:17 PM Subject: [SQL] generated dates from record dates - suggestions Hi folks. I've got a table with three dates which are populated from an external sour

Re: [SQL] Lowest 2 items per

2012-06-02 Thread Oliveiros
Nice resource, msi77. Thanx for sharing. I wasn't aware of none of these techniques, actually, so I tried to start from scratch, but I should've realized that many people in the past had the same problem as Mike and I should have googled a little instead of trying to re-invent the wheel. Anyway,

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Oliveiros d'Azevedo Cristina
I only made grammatical changes necessary for the query to function (adding a missing FROM, fully qualifying "SELECT Make" as " SELECT subquery2.Make", etc.) I tried changing the join type to right and left but that did not have the desired result. * I see... If we add a query with a union tha

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Oliveiros d'Azevedo Cristina
Oliver, I had to make a few grammatical corrections on your query to get it to run, but once I did it gave me almost correct results. It leaves out all of the printer models that only have one consumable with a cost. Some printers might have more than two black inks and some might have only one

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Oliveiros d'Azevedo Cristina
2.make,subquery2. model, subquery2.color,subquery2.type,subquery1.cpp ORDER BY make, model; - Original Message - From: "Oliveiros d'Azevedo Cristina" To: "Relyea, Mike" ; Sent: Friday, June 01, 2012 3:56 PM Subject: Re: [SQL] Lowest 2 items per Hi, Mike, Can you

Re: [SQL] Lowest 2 items per

2012-06-01 Thread Oliveiros d'Azevedo Cristina
Hi, Mike, Can you tell me if this gives what you want, and if it doesn't, what is the error reported, or wrong result ? This is untested query, so Im not sure about it. Best, Oliver SELECT make, model, color,type, subquery1.cpp, min(cost/yield) as cpp2 ( SELECT printers.make, printers.model,

Re: [SQL] left outer join only select newest record

2012-05-24 Thread Oliveiros d'Azevedo Cristina
Hi, Gary, Unless I'm mistaken this didn't give what you need. Could you please tell me (if you have time) the error returned or wrong result, just for my own understanding of where I've gone sideways on this...? Best, Oliver - Original Message - From: "Oliveiro

Re: [SQL] left outer join only select newest record

2012-05-23 Thread Oliveiros d'Azevedo Cristina
= u.ud_pex_registration where s_stock_no = 'UL15470'; GROUP s_stock_no,s_regno,s_vin,s_created ) subq JOIN used_diary sec ON subq.m = sec.ud_id Best, Oliver - Original Message - From: "Oliveiros d'Azevedo Cristina" To: "Gary Stainburn" ; Sent: Wednesday, May 23, 20

Re: [SQL] left outer join only select newest record

2012-05-23 Thread Oliveiros d'Azevedo Cristina
09:15:31.569471 | 42363 | 2012-05-16 (2 rows) On Wednesday 23 May 2012 10:37:31 Oliveiros d'Azevedo Cristina wrote: Gary, You describe two tables vehicle stock and tax requests. The former has a one-to-many relationship wit the second one, right? But your query involves stock details and used_diar

Re: [SQL] left outer join only select newest record

2012-05-23 Thread Oliveiros d'Azevedo Cristina
Gary, You describe two tables vehicle stock and tax requests. The former has a one-to-many relationship wit the second one, right? But your query involves stock details and used_diary. What is the relationship of these two new tables to the previous ones? Could you please kindly supply an ex

Re: [SQL] How change col name during query to use it in where clause

2012-05-04 Thread Oliveiros d'Azevedo Cristina
I'm affraid you can't. AFAIK, WHERE clause is processed before the SELECT output expressions Best, Oliveiros - Original Message - From: "Marcel Ruff" To: Sent: Friday, May 04, 2012 11:25 AM Subject: [SQL] How change col name during query to use it in where

Re: [SQL] Aggregate and join problem

2012-03-01 Thread Oliveiros d'Azevedo Cristina
Great to Hear! Best, Oliver - Original Message - From: Swärd Mårten To: Oliveiros d'Azevedo Cristina ; pgsql-sql@postgresql.org Sent: Thursday, March 01, 2012 11:01 AM Subject: Re: [SQL] Aggregate and join problem It worked like a charm! Many thanks for that

Re: [SQL] Aggregate and join problem

2012-03-01 Thread Oliveiros d'Azevedo Cristina
here. You'll have to substitute my col1, col2, etc with your actual column names. Best, Oliveiros SELECT query1.t1_id, t1.col2,t1.col3,t1.col4, query1.minimum FROM ( SELECT t3.col2 as t1_id, MIN(t2.col2) as minimum FROM Table_3 t3 JOIN Table_2 t2 ON t3.col1 = t2.col1 GROUP BY t3.col2 ) query1 JO

Re: [SQL] Another constant in foreign key problem.

2012-02-22 Thread Oliveiros d'Azevedo Cristina
two cents Best, Oliveiros I've googled this but can't find a suitable solution. Can anyone help please. -- Gary Stainburn Group I.T. Manager Ringways Garages http://www.ringways.co.uk -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to you

Re: [SQL] update column

2012-02-10 Thread Oliveiros d'Azevedo Cristina
UPDATE admin SET parent = SUBSTR(id,1,4); Doesn't it do what you want? Best, Oliveiros - Original Message - From: "ssylla" To: Sent: Thursday, February 09, 2012 1:58 AM Subject: [SQL] update column Dear list, sorry, I already posted this, but it did not se

Re: [SQL] sql query problem

2012-01-15 Thread Oliveiros
What does a 0 state mean? Failed? And a 1 state? Passed? Best, Oliveiros 2012/1/14 Alok Thakur > Dear All, > > I have two tables one contains details of user and other contains > result. The details are: > 1. UserTable - id, name, phone > 2. result - id, question_id, user_

Re: [SQL] Self-Join

2011-12-06 Thread Oliveiros d'Azevedo Cristina
I have not. I've already skimmed through it. Indeed, it is very interesting Thanx , Scott Best, Oliver - Original Message - From: "Scott Swank" To: "Oliveiros d'Azevedo Cristina" Cc: "Abhinandan Raghavan" ; Sent: Tuesday, December 06, 2

Re: [SQL] Self-Join

2011-12-06 Thread Oliveiros d'Azevedo Cristina
't scale well if you have many more items beyond three... Best, Oliveiros - Original Message - From: Abhinandan Raghavan To: pgsql-sql@postgresql.org Sent: Tuesday, December 06, 2011 1:57 PM Subject: [SQL] Self-Join Hi, I'm looking to frame an SQL statement

Re: [SQL] how to temporally disable foreign key constraint check

2011-10-21 Thread Oliveiros d'Azevedo Cristina
Something like ALTER TABLE t_yourtable DROP CONSTRAINT and then ALTER TABLE t_yourtable ADD FOREIGN KEY ? Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Friday, October 21, 2011 2:36 PM Subject: [SQL] how to temporally disable foreign key constraint che

Re: [SQL] Add one column to another

2011-08-25 Thread Oliveiros d'Azevedo Cristina
Something like this...? SELECT first_name,surname, email1 || ';' || email2 FROM t_your_table; Best, Oliver - Original Message - From: "gvim" To: "pgsql sql" Sent: Thursday, August 25, 2011 3:21 PM Subject: [SQL] Add one column to another I have to deal with a table which contain

Re: [SQL] Using variables in select

2011-08-12 Thread Oliveiros d'Azevedo Cristina
like you need a function something like CREATE FUNCTION customer_table(int) RETURNS customer_table AS $$ SELECT COUNT(DISTINCT costumer_id),AVG(price) FROM customer_table WHERE productid = $1 $$ LANGUAGE SQL; HTH Best, Oliveiros - Original Message - From: "tlund79"

Re: [SQL] Mysterious column "name"

2011-08-09 Thread Oliveiros d'Azevedo Cristina
Strange... Tables have hidden columns but AFAIK, "name" is not one of them... http://www.postgresql.org/docs/9.0/interactive/ddl-system-columns.html Best, Oliveiros - Original Message - From: "Nikolay" To: Sent: Thursday, August 04, 2011 3:50 PM Subject: [SQ

Re: [SQL] [NOVICE] Compare rows

2011-07-14 Thread Oliveiros d'Azevedo Cristina
- Original Message - From: LALIT KUMAR To: Oliveiros d'Azevedo Cristina Hi, I do have order of rows. The problem originally is: I need to set all flag with value 0 to -1 whose next row has flag as 1. This is to be done for each city separetly, i.e. flag of last r

Re: [SQL] Merge overlapping time-periods

2011-06-15 Thread Oliveiros d'Azevedo Cristina
(IMHO) as much as 1 2000-01-01 2000-03-31 1 2000-04-01 2000-05-31 are. Isn't my understanding correct? Best, Oliveiros (SELECT x."ID",x."BEG",x."END" FROM mytable x LEFT JOIN ( SELECT a."ID" as xid ,a."BEG" as xbeg,a."END&

Re: [SQL] Merge overlapping time-periods

2011-06-15 Thread Oliveiros d'Azevedo Cristina
Howdy, Marcel, In the example output you provided the ID = 2 should have just one record...Ain't I right? Best, Oliveiros - Original Message - From: Jira, Marcel To: 'pgsql-sql@postgresql.org' Sent: Wednesday, June 15, 2011 4:23 PM Subject: [SQL] Merge o

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Oliveiros d'Azevedo Cristina
;t be overlapping, right? Best, Oliveiros - Original Message - From: "Andreas" To: Sent: Thursday, June 09, 2011 2:43 PM Subject: [SQL] need help with some aggregation magic hi, I have a log-table that stores events of users and projects like this ( user_id integer, project

Re: [SQL] Select and merge rows?

2011-05-05 Thread Oliveiros
Howdy! Is there a maximum ceilling of three values per order ID? or an ID can have an arbitrary number of values? Best, Oliveiros 2011/5/5 Claudio Adriano Guarracino > Hello! > I have a doubt about a query that I tried to do, but I cant.. > This is the scenario: > I have a

Re: [SQL] How to realize ROW_NUMBER() in 8.3?

2011-04-20 Thread Oliveiros d'Azevedo Cristina
version... Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Wednesday, April 20, 2011 4:45 PM Subject: [SQL] How to realize ROW_NUMBER() in 8.3? Hello, ROW_NUMBER() is only ready in 8.4. For 8.3, is there a simple way to get row_number select row_number(),

Re: [SQL] data import: 12-hour time w/o AM/PM

2011-02-08 Thread Oliveiros d'Azevedo Cristina
Howdy, Tarlika. If the data doesn't bring the AM/PM how are you supposed to distinguish between,say, 10pm and 10am ? Does it always start at 10:30am? So 10am never arises? Best, Oliveiros - Original Message - From: "Tarlika Elisabeth Schmitz" To: Sent: Tuesday, Fe

Re: [SQL] Get days between two dates?

2011-01-31 Thread Oliveiros d'Azevedo Cristina
That's precisely what I think.. :-| - Original Message - From: "Kenneth Marshall" To: "Emi Lu" Cc: Sent: Monday, January 31, 2011 4:39 PM Subject: Re: [SQL] Get days between two dates? On Mon, Jan 31, 2011 at 10:50:43AM -0500, Emi Lu wrote: Good morning, Is there an existing me

Re: [SQL] Get days between two dates?

2011-01-31 Thread Oliveiros d'Azevedo Cristina
Doesn't the SELECT you indicated do what you need? Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Monday, January 31, 2011 3:50 PM Subject: [SQL] Get days between two dates? Good morning, Is there an existing method to get days between two date

Re: [SQL] how to get row number in select query

2011-01-27 Thread Oliveiros d'Azevedo Cristina
Hi Oliveiros, Howdy! If it is to order in ascendent fashion by, say, lname, one possibility would be SELECT COUNT(b.*) as row_number, a.lname,a.gname FROM "Table1" a, "Table2" b WHERE a.lname >= b.lname GROUP BY a.lname,a.gname ORDER BY row_number If you want

Re: [SQL] how to get row number in select query

2011-01-26 Thread Oliveiros d'Azevedo Cristina
version 8.3 doesn't have any "non-standard SQL" way to get a row number, but it is possible that something like that has been introduced in later versions... Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Wednesday, January 26, 2011 4:11 PM

Re: [SQL] how to get row number in select query

2011-01-26 Thread Oliveiros d'Azevedo Cristina
Hi, Lu Ying. How do you define which row is #1 ? And #2 ? E.g. Ordered by lname? Or gname...? Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Wednesday, January 26, 2011 4:11 PM Subject: [SQL] how to get row number in select query Good morning, For

Re: [SQL] return records with more than one occurrences

2011-01-07 Thread Oliveiros d'Azevedo Cristina
Howdy, Tarsis. Please try this out. SELECT a.id, id_table1,a.name FROM "Table2" a NATURAL JOIN (SELECT id_table1 "Table2" GROUP BY id_table1 HAVING COUNT(*) > 1) b Tell me if it worked or not, and if it didn't the errors/uncorrect results. Best, Olive

Re: [SQL] Insert row in 1.10.1 and 1.10.3

2010-11-26 Thread Oliveiros d'Azevedo Cristina
Could you please include the full insert SQL statement? Best, Oliveiros - Original Message - From: "ndias" To: Sent: Friday, November 26, 2010 4:22 PM Subject: [SQL] Insert row in 1.10.1 and 1.10.3 Hello to all, I have a question regarding the behavior of insert row

Re: [SQL] group by hour + distinct

2010-11-26 Thread Oliveiros d'Azevedo Cristina
Ciao * Olá! for each hour it will count the number of distinct user_id's there are . If I understood correctly what you need... Can you please test it and see if it is OK for your needs? With me, it worked on the sample data you provided Yes! Simply perfect! * Great to hear it worked

Re: [SQL] group by hour + distinct

2010-11-26 Thread Oliveiros d'Azevedo Cristina
Howdy, Michelle, If you write something like this, SELECT hour , COUNT(id_user) as count FROM ( SELECT EXTRACT(hour from my_date) as hour, id_user FROM michelle GROUP BY EXTRACT(hour from my_date),id_user )subquery GROUP BY hour for each hour it will count the number of distinct user_id's ther

Re: [SQL] "compressing" consecutive values into one

2010-11-23 Thread Oliveiros d'Azevedo Cristina
Salut, Louis-David, Can you please state the columns belonging to price table and give a concrete example? Say, data before and data after you want to do? Thank you A bien-tôt, Oliveiros - Original Message - From: "Louis-David Mitterrand" To: Sent: Tuesday, November 23,

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-18 Thread Oliveiros d'Azevedo Cristina
- Original Message - From: Oliveiros d'Azevedo Cristina To: John Lister ; pgsql-sql@postgresql.org Sent: Wednesday, November 17, 2010 4:09 PM Subject: Re: [SQL] obtaining difference between minimum value and next in size Hi, John. I am not familiar with the func

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread Oliveiros d'Azevedo Cristina
Hi, John. I am not familiar with the functions Tom's indicated and I'm sure they constitute a much more straightfoward to solve your problem. Meanwhile, if you'd like to solve it with just SQL give this a try and see if it gives you the result you want Best, Oliveiros SELECT

Re: [SQL] identifying duplicates in table with redundancies

2010-09-29 Thread Oliveiros d'Azevedo Cristina
Hallo Andreas, I reduced the problem to the innermost query: 1) SELECT DISTINCT trainer_id, trainer_name FROM student This results in a sequential table scan. Execution time 7500ms. 2) I created an INDEX ON (trainer_id, trainer_name). Then I had an index scan instead, which still cost 7000ms.

Re: [SQL] identifying duplicates in table with redundancies

2010-09-28 Thread Oliveiros d'Azevedo Cristina
answer. There are many people on this list that can help you better Best, Oliveiros - Original Message - From: "Tarlika Elisabeth Schmitz" To: Sent: Monday, September 27, 2010 5:54 PM Subject: Re: [SQL] identifying duplicates in table with redundancies On Fri, 24 Sep 2

Re: [SQL] identifying duplicates in table with redundancies

2010-09-24 Thread Oliveiros d'Azevedo Cristina
Howdy, Tarlika. First, did you past correctly your query into your mail? I am asking this because your query doesn't seem work for me, it returns an empty list :-| Your most nested query, this one, -- distinct trainer id-name select distinct on (trainer_id,trainer_name)

Re: [SQL] unique fields

2010-09-23 Thread Oliveiros d'Azevedo Cristina
Howdy, Adrian Dunno if this is exactly what you want SELECT * FROM ( SELECT chr,cfrom,cto,count(*) as numberOfDuplicates FROM t_fairly_large_table GROUP BY chr,cfrom,cto ) x NATURAL JOIN t_fairly_large_table y WHERE numberOfDuplicates > 1 The idea of this (untested) query is to produce somet

Re: [SQL] Help with queries.

2010-09-21 Thread Oliveiros d'Azevedo Cristina
Howdy, Adrian, Please see my questions below snps table id | sample_id | chromosome | from | to | 1 1chr1 10 11 2 1 chr1 14 15 3 2

Re: [SQL] all the table values equal

2010-09-21 Thread Oliveiros d'Azevedo Cristina
Yes. All the users that have only one value into the "value" column and that value is NN. Understood. Try the query from the previous mail, adding the clause WHERE "value" = NN as I did explain. Or will you need to find all the users that don't change value with just one query? And the

Re: [SQL] all the table values equal

2010-09-21 Thread Oliveiros d'Azevedo Cristina
d the clause "WHERE "value" = x -- x=the specific value you want to look for to the query above. It'll return just the id_user(s) that have just the "value" x. Please try it out and feel free to get back to me if it didn't work or if it didn't solve your

Re: [SQL] all the table values equal

2010-09-21 Thread Oliveiros d'Azevedo Cristina
It would help if you explain a little better the background of the problem you're trying to solve. You want to find all the user IDs which have the same value on a given time interval? Is my understanding correct? Yes. Re-reading my post I saw that I could explain better! id_user | value

Re: [SQL] all the table values equal

2010-09-20 Thread Oliveiros d'Azevedo Cristina
time interval? Is my understanding correct? Best, Oliver - Original Message - From: "Michele Petrazzo - Unipex" To: "Oliveiros d'Azevedo Cristina" Cc: Sent: Friday, September 17, 2010 4:45 PM Subject: Re: [SQL] all the table values equal Oliveiros d'

Re: [SQL] all the table values equal

2010-09-17 Thread Oliveiros d'Azevedo Cristina
Howdy , Michele, Give this a try SELECT id_user FROM t_your_table WHERE datetime BETWEEN A -- plug here beginning of interval AND B-- and end here GROUP BY id_user HAVING COUNT(*) = -SUM(value) Then tell me if it gives you what you want Best, Oliveiros Cristina - Original Message

Re: [SQL] Extract created and last modified data

2010-08-19 Thread Oliveiros d'Azevedo Cristina
Howdy, Gordon. This query is an attempt to replicate your items table with data just from changelog table. Could you please try it out? Best, Oliveiros SELECT itm_id,usr_id_create, itm_date_create, usr_id_modify, itm_date_modify FROM ( SELECT a.itm_id, a.usr_id as usr_id_create, create as

Re: [SQL] join table problem

2010-08-04 Thread Oliveiros d'Azevedo Cristina
this (untested) query a try SELECT name,MIN(company_name) FROM plant a JOIN plant_seed_supplier associative ON plant_id = a.id JOIN seed_supplier b ON b.id = supplier_id GROUP BY name Best, Oliveiros -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] grouping subsets

2010-07-30 Thread Oliveiros d'Azevedo Cristina
I See. And the analysis you need to do, the sum of the rows with the same keys (until they change) will have to be done over all table? Or just over some predefined interval ? Best, Oliveiros - Original Message - From: "Rainer Stengele" Newsgroups: gmane.comp.db.postgre

Re: [SQL] grouping subsets

2010-07-29 Thread Oliveiros d'Azevedo Cristina
Fine. Please advice me, How long can your table be? Thousands? Millions of records? Do you really need it in pure SQL ? It seems to me that it might be possible, I'm just affraid that the query would become too complex and thus slow... Best, Oliveiros - Original Message -

Re: [SQL] grouping subsets

2010-07-29 Thread Oliveiros d'Azevedo Cristina
e day with several sets? Best, Oliveiros - Original Message - From: "Rainer Stengele" Newsgroups: gmane.comp.db.postgresql.sql To: "Oliveiros d'Azevedo Cristina" Cc: <> Sent: Thursday, July 29, 2010 10:41 AM Subject: Re: grouping subsets Howdy Cristina,

Re: [SQL] grouping subsets

2010-07-27 Thread Oliveiros d'Azevedo Cristina
ou have several thousands of records on your table it will become slow... Best, Oliveiros SELECT SUM(tudo.parcela),tudo.a FROM ( SELECT fo.parcela,fo.a,fo.b,fo.c,MIN(th.c) as d FROM ( SELECT se.a as parcela,se.b as a,se.c as b, MAX(pr.c) as c FROM yourTable se LEFT JOIN ( SELECT a.* FROM y

Re: [SQL] grouping subsets

2010-07-22 Thread Oliveiros d'Azevedo Cristina
Howdy, Rainer. Please advice me, The dates always follow that sequential pattern? Or can be holes on the dates sequence? Best, Oliveiros - Original Message - From: "Rainer Stengele" To: Sent: Thursday, July 22, 2010 9:09 AM Subject: [SQL] grouping subsets Hi, havi

Re: [SQL] Outer join construction step :strange results

2010-06-28 Thread Oliveiros d'Azevedo Cristina
forget to CC to list, it's always possible that someone with more knowledge than me might help you faster Best, Oliveiros -- 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] Outer join construction step :strange results

2010-06-28 Thread Oliveiros d'Azevedo Cristina
Oliveiros d'Azevedo Cristina wrote: Howdy, Cedric . Before analysing this problem of yours further, I 'd like you to kindly clarify me some points, please I have table following tables T0,T1,T2,T3, T1T2 with -T0(id, fk_T1) -T1(id ) -T2(id, fk_T3) -T1T2(fk_T1,fk_T2) -T3 (id)

Re: [SQL] Outer join construction step :strange results

2010-06-28 Thread Oliveiros d'Azevedo Cristina
ndition always truth ? Maybe I am lacking some sql knowledge ... Thanks in advance for advising me Best, Oliveiros -- 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] Some insight on the proper SQL would be appreciated

2010-06-08 Thread Oliveiros d'Azevedo Cristina
Howdy, Aaron, For me this is not an easy question, specially when I don't have your data here on my PC to test. But as a first approach, try this query. It is designed to give you the oldest 5 entries. But, be aware that this is non-tested code. Be prepared for it to not work or even to cont

Re: [SQL] sum an alias

2010-06-04 Thread Oliveiros d'Azevedo Cristina
); Maybe I 'm misunderstanding the background of what you want to do Best, Oliveiros -- 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 construct sql

2010-06-02 Thread Oliveiros
Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count) from page_count group by page_count_pdate. Best, Oliveiros - Original Message - From: "Wes James" To: Sent: Wednesday, June 02, 2010 5:48 PM Subject: [SQL] how to construct s

Re: [SQL] LEFT OUTER JOIN issue

2010-04-21 Thread Oliveiros
, ct.heur And drop the WHERE clause. See if it gives the results you intended. Best, Oliveiros - Original Message - From: Oliveiros To: Thomas BOURIMECH ; pgsql-sql@postgresql.org Sent: Wednesday, April 21, 2010 1:53 PM Subject: Re: [SQL] LEFT OUTER JOIN issue Hi

Re: [SQL] LEFT OUTER JOIN issue

2010-04-21 Thread Oliveiros
Hi, Thomas. I believe it is because of your WHERE clause, which is filtering out the nulls from hp table. According to WHERE hp.poste_idposte = 275 You only want registers that have hp.poste_idposte = 275, not the null ones. HTH Best, Oliveiros - Original Message

Re: [SQL] How to max() make null as biggest value?

2010-04-20 Thread Oliveiros
this is "air code", but if you use count on a column with nulls the return value is different from count(*) HTH Best, Oliveiros Cristina - Original Message - From: "Feixiong Li" To: Sent: Wednesday, April 14, 2010 5:33 AM Subject: [SQL] How to max() make null as

Re: [SQL] check constraint on multiple tables?

2010-03-03 Thread Oliveiros
rop the relation between type and category. The cabin table would then work as an associative table between category and type. Ain't saying your schema is wrong, maybe you have strong reasons to do that that way, that I am not realizin by now... Best, Oliveiros d'Azevedo Cristina -- S

Re: [SQL] UNION or LEFT JOIN?

2010-02-16 Thread Oliveiros
7;t have a register for that pair (îd_cabin,id_cruise), how do you know that cabin belongs to that cruise, in this case, cruise nº 1? Best, Oliveiros 2010/2/16 Louis-David Mitterrand > > Here is the basic schema: > >

Re: [SQL] "left join" not working?

2010-02-12 Thread Oliveiros C,
Yes, because your WHERE is something that comes after the operation of the LEFT JOIN, in practice, defeating the purpose you intented. On your second query the p.id_line = 1 doesn't do that because it is part of the LEFT JOIN itself.. HTH Best, Oliveiros d'Azevedo Cristina

Re: [SQL] "left join" not working?

2010-02-12 Thread Oliveiros C,
My first guess is that NULL fails the condition on your WHERE clause, p.id_line = 1 So your WHERE clause introduces an additional level of filtering that filters out the NULLs coming from the LEFT JOIN... Didn't do any tests, it's just a guess... Best, Oliveiros - Origin

Re: [SQL] selecting rows tagged with "a" but not "b"

2010-02-01 Thread Oliveiros C,
o give you more advises Thank you Best, Oliveiros - Original Message - From: <8q5tmky...@sneakemail.com> To: Sent: Monday, February 01, 2010 1:31 PM Subject: [SQL] selecting rows tagged with "a" but not "b" Hi, I have a two tables: article articleID, na

Re: [SQL] Is there any function to test for numeric ips?

2009-12-11 Thread Oliveiros C,
depth subjects like pgplsql not to mention regular expressions Thanx a lot for your fast help, Best, Oliveiros - Original Message - From: "Alvaro Herrera" To: "Oliveiros C," Cc: Sent: Friday, December 11, 2009 4:28 PM Subject: Re: [SQL] Is there any functio

[SQL] Is there any function to test for numeric ips?

2009-12-11 Thread Oliveiros C,
ow very little ( nothing, actually...) about function creation in pgplsql, so, before investing in learning, I would like to know if there is any built in function that does the trick, so I can skip the (potential) learning curve. So far, I've googled up and down but found none Thanx in advance for your kind and valuable help Best, Oliveiros

Re: [SQL] need nelp with aggregate functions

2009-11-19 Thread Oliveiros C,
appearing more than once... It's basically that... Hope this helped Best, Oliveiros - Original Message - From: Another Trad To: Oliveiros C, Cc: pgsql-sql@postgresql.org Sent: Wednesday, November 18, 2009 5:37 PM Subject: Re: [SQL] need nelp with aggregate functions

Re: [SQL] need nelp with aggregate functions

2009-11-18 Thread Oliveiros C,
Try substituting the SELECT count(c) as qtd_client,count(cm) as qtd_computers by SELECT count( DISTINCT c.cliente_id) as qtd_client,count(/* put here the primary key of the computer table */ ) as qtd_computers Then tell me if it output what you want Best, Oliveiros - Original Message

Re: [SQL] How to order varchar data by word

2009-10-20 Thread Oliveiros C,
Hello, Adrian, thanks for the links. I enjoyed the technique on the end of the second page (on the version 8.3 with comments), the shadow column trick. Given that LC_COLLATE is immutable, unless a new database is created, I guess I'll give the shadow column a try. Best, Oliv

Re: [SQL] How to order varchar data by word

2009-10-20 Thread Oliveiros C,
Best, Oliveiros - Original Message - From: "Tom Lane" To: "Oliveiros C," Cc: "Adrian Klaver" ; Sent: Monday, October 19, 2009 6:32 PM Subject: Re: [SQL] How to order varchar data by word "Oliveiros C," writes: If any one can explain me exact

Re: [SQL] How to order varchar data by word

2009-10-19 Thread Oliveiros C,
(zero). According to ASCII numeric codes, it shouldn't If any one can explain me exactly how the order by clause works on varchars, I 'd really appreciate it. I've already examined documentation carefully, but couldn't find it. Maybe I looked on the wrong place... Best,

[SQL] How to order varchar data by word

2009-10-14 Thread Oliveiros C,
Hello, list. I have a table with a varchar field that I would like to order by word, not by ordinal, which seems to be the default on postgres. Does anyone have a clue on how this can be done? Many thanx in advance, Best, Oliveiros

Re: [SQL] simple (?) join

2009-09-28 Thread Oliveiros C,
Hello, Gary. thank you for your e-mail This is a slightly modified version of the query I sent you on first place (have you tried it out?). It will return (I hope :) the full orders record plus the maximum ol_timestamp and respective o_user. HTH Best, Oliveiros SELECT subquery

Re: [SQL] simple (?) join

2009-09-25 Thread Oliveiros C,
group by o_id because the MAX(ol_timestamp) will receive the name max, not ol_timestamp, and probably the parser will complain that column ol_timestamp does not exist. Ain't I right? Best, Oliveiros - Original Message - From: justin To: David W Noon Cc: pgsq

Re: [SQL] simple (?) join

2009-09-24 Thread Oliveiros C,
Hmm...no, it seems, it is not allowable to use orders.* on a GROUP BY clause. Unless you've defined for the table something called an ordering operator. If you didn't, you'll have to include all the fields from the orders table in the GROUP BY clause HTH Best, Oliveiros

Re: [SQL] simple (?) join

2009-09-24 Thread Oliveiros C,
, orders.next_field, etc... Best, Oliveiros - Original Message - From: "Gary Stainburn" To: Sent: Thursday, September 24, 2009 4:16 PM Subject: [SQL] simple (?) join Hi folks. I have two tables create table orders ( o_id serial primary key ... ); create table orders_log ( ol_id seri

[SQL] Differences between bit string constant sintax

2009-09-09 Thread Oliveiros C,
.7, compiled by Visual C++ build 1400" Thanx in advance for your help Best, Oliveiros

Re: [SQL] simple join is beating me

2009-07-13 Thread Oliveiros
place the RIGHT by FULL Best, Oliveiros 2009/7/13 Gary Stainburn > Hi Oliveiros, > > Thank you for this. However, this does not give me what I want. > > If a date exists where we have orders but no deliveries the row does not > appear. > > I have tried doing a union to lin

Re: [SQL] simple join is beating me

2009-07-13 Thread Oliveiros
query here */) ordersQuery NATURAL RIGHT JOIN (/* ur second query goes here */) deliveryQuery ORDER BY deliveryQuery.o_date DESC Tararabite, Oliveiros @Allgarve 2009/7/13 Gary Stainburn > hi folks > > i have the following: > > select o_ord_date as o_date, count(o_id) as orders >from

Re: [SQL] Bucketing Row Data in columns

2009-06-25 Thread Oliveiros Cristina
l) Getting the counts takes half the time, making the flattened report takes half the time. Oliveiros Cristina wrote: Hello, Sandeep, I am not sure if this is what you want. I came up with this query SELECT * FROM (SELECT user_id,SUM(amount) as day1 FROM t1 WHERE create_timestamp = '2

Re: [SQL] Bucketing Row Data in columns

2009-06-25 Thread Oliveiros Cristina
are fixed at 3. So, you mean the table output will always have 4 columns? 3 days plus one for user_id ? If you want 20 buckets it must be a different query... Could you please clarify what you mean when you say that you want to get a bucket unlimited ? Best, Oliveiros - Original Messag

Re: [SQL] Composite primary keys

2009-06-23 Thread Oliveiros Cristina
error informing that primary key constraint is being violated. But IMHO the first INSERT is legal SQL.... Best, Oliveiros - Original Message - From: "Harald Fuchs" To: Sent: Tuesday, June 23, 2009 4:14 PM Subject: [SQL] Composite primary keys I tried to throw some invalid S

Re: [SQL] Obtaining a limited number of records from a long query

2009-05-25 Thread Oliveiros Cristina
Thank you for pointing it out, Ivan. The query I am trying to restrict output for happens to be an ORDER BY query. Actually I wasn't aware of this detail. I'll leave a mental note for myself that results might be unexpected for not ORDER BY queries Best, Oliveiros - Origin

Re: [SQL] Obtaining a limited number of records from a long query

2009-05-25 Thread Oliveiros Cristina
Thanks a million, Andy. It's precisely what I needed, Indeed! Best, Oliveiros - Original Message - From: "Andy Shellam" To: "Oliveiros Cristina" Cc: Sent: Monday, May 25, 2009 2:45 PM Subject: Re: [SQL] Obtaining a limited number of records from a l

[SQL] Obtaining a limited number of records from a long query

2009-05-25 Thread Oliveiros Cristina
Dear List, Is there any way to force a query to return just a few records? For ex, returning just the first ten rows from a long ORDER BY query ? And then, eventually, obtaining the remaining records at a later time, or in background? Thanks in advance for your help, Best, Oliveiros

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread Oliveiros Cristina
I guess this is pretty much the same as doing SELECT message.id,topic.topic,message.message FROM topics JOIN messages ON topics.id = message.topic ORDER BY message.ID Ain't I right? Best, Oliveiros - Original Message - From: James Kitambara To: Richard Ekblom Cc:

[SQL] performance question

2009-05-08 Thread Oliveiros Cristina
by the former condition) Frankly, I cannot understand the reason for this, it seems the planner is taking radically diferent plans on the two conditions (they are below). I have an index on all the fields used in the query. Can anyone help me in fixing this, please? Thanks in advance for your kind

[SQL] Re: [SQL] Relatorio da composiçao de FKs e PKs

2009-03-19 Thread Oliveiros Cristina
Escreve a tua dúvida em inglês, por favor, isto é uma lista de mailing em ingles. He wants to do a report with the composition of each foreign key and primary key, not just their names. He wants to know where postgres keeps that in catalog. Best, Oliveiros - Original Message

Re: [SQL] uso de dblink en php

2009-03-05 Thread Oliveiros Cristina
Escribe tu duda en ingles, por favor Saludos, Oliveiros - Original Message - From: Jhonny Velasquez c. To: pgsql-sql@postgresql.org ; pgsql-...@postgresql.org Sent: Thursday, March 05, 2009 3:50 PM Subject: [SQL] uso de dblink en php hola a todos estoy programando

Re: [SQL] Grass Root Protectionism

2009-02-09 Thread Oliveiros Cristina
Just follow Google's motto "Don't be evil" :-) We are all engineers from the same field, so Let's all be friends Best, Oliveiros - Original Message - From: Boycott Tech Forums To: pgsql-sql@postgresql.org Sent: Sunday, February 08, 2009 6:40 AM

  1   2   >