Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-03-02 Thread Ben Morrow
Quoth lists-pg...@useunix.net (Wayne Cuddy): > On Thu, Feb 28, 2013 at 06:02:05PM +, Ben Morrow wrote: > > > > (If you wanted to you could instead rename the table, and use rules on > > the view to transform DELETE to UPDATE SET state = 'deleted' and copy > > across INSERT and UPDATE...) > >

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-03-02 Thread Wayne Cuddy
On Thu, Feb 28, 2013 at 06:02:05PM +, Ben Morrow wrote: > Quoth m...@summersault.com (Mark Stosberg): > > > > We are working on a project to start storing some data as "soft deleted" > > (WHERE state = 'deleted') instead of hard-deleting it. > > > > To make sure that we never accidentally exp

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Mark Stosberg
On 02/28/2013 02:08 PM, Tom Lane wrote: > Mark Stosberg writes: >> # Explicitly grant access to the view. >> db=> grant select on entities_not_deleted to myuser; >> GRANT > >> # Try again to use the view. Still fails >> db=> SELECT 1 FROM entities_not_deleted WHERE some_col = 'y'; >> ERROR: perm

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Tom Lane
Mark Stosberg writes: > # Explicitly grant access to the view. > db=> grant select on entities_not_deleted to myuser; > GRANT > # Try again to use the view. Still fails > db=> SELECT 1 FROM entities_not_deleted WHERE some_col = 'y'; > ERROR: permission denied for relation entities What's failin

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Mark Stosberg
On 02/28/2013 01:02 PM, Ben Morrow wrote: > Quoth m...@summersault.com (Mark Stosberg): >> >> We are working on a project to start storing some data as "soft deleted" >> (WHERE state = 'deleted') instead of hard-deleting it. >> >> To make sure that we never accidentally expose the deleted rows thro

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Ben Morrow
Quoth m...@summersault.com (Mark Stosberg): > > We are working on a project to start storing some data as "soft deleted" > (WHERE state = 'deleted') instead of hard-deleting it. > > To make sure that we never accidentally expose the deleted rows through > the application, I had the idea to use a

[SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Mark Stosberg
We are working on a project to start storing some data as "soft deleted" (WHERE state = 'deleted') instead of hard-deleting it. To make sure that we never accidentally expose the deleted rows through the application, I had the idea to use a view and permissions for this purpose. I thought I coul

Re: [SQL] need help

2013-02-22 Thread denero team
Hey, Thanks Russell and all others. The query worked well. I got result what I expected. Thanks again, Dhaval On Fri, Feb 22, 2013 at 4:11 PM, denero team wrote: > Thanks Russell, > > let me check the query. > > On Fri, Feb 22, 2013 at 2:56 PM, Russell Keane > wrote: >>> Or every destinatio

Re: [SQL] need help

2013-02-22 Thread Russell Keane
> Or every destination location of the product in that time period? Ok, I've had another look at this this morning on the assumption you need every location that a product has been in that time period. This also assumes you're getting all the data you're interested in from the product_move table

Re: [SQL] need help

2013-02-22 Thread denero team
Thanks Russell, let me check the query. On Fri, Feb 22, 2013 at 2:56 PM, Russell Keane wrote: >> Or every destination location of the product in that time period? > > Ok, I've had another look at this this morning on the assumption you need > every location that a product has been in that time

Re: [SQL] need help

2013-02-22 Thread Russell Keane
> Sorry, why do you need the joins? > > Best, > Oliver Strictly speaking, for the examples and results given, the joins are pointless when you can get all the info from the 'move' table (but then the problem is like the 'hello world' of SQL) But then the other 2 tables are completely redundant

Re: [SQL] need help

2013-02-21 Thread Jaime Casanova
On Thu, Feb 21, 2013 at 3:20 PM, denero team wrote: > Hi, > > Thanks for replying me. yes you are right at some level for my case. > but its not what I want. I am explaining you a case by example. > [...] > > Now I really don't know how to do this. > > can you advise me more ? > I'm not really su

Re: [SQL] need help

2013-02-21 Thread Oliver d'Azevedo Cristina
Sorry, why do you need the joins? Best, Oliver Enviado via iPhone Em 21/02/2013, às 09:28 PM, Russell Keane escreveu: >>> Now I really don't know how to do this. >>> >>> can you advise me more ? >>> >>> >>> Thanks, >>> >>> Dhaval >> >> >> I think these are the sqls you are looking for: >

Re: [SQL] need help

2013-02-21 Thread Russell Keane
> > Now I really don't know how to do this. > > > > can you advise me more ? > > > > > > Thanks, > > > > Dhaval > > > I think these are the sqls you are looking for: > > SELECT pm.id as move_id, p.id as product_id, l.id as location_id > FROM product_move pm inner join product p on pm.product_id

Re: [SQL] need help

2013-02-21 Thread Russell Keane
> Consider following are data in each table > > Location : > id , name, code > 1, stock, stock > 2, customer, customer > 3, asset, asset > > Product : > id, name, code, location > 1, product1, p1, 1 > 2, product2, p2, 3 > > > Product_Move : > id, product_id, source_location, destination_locatio

Re: [SQL] need help

2013-02-21 Thread Oliver d'Azevedo Cristina
SELECT move_id, product_id,destination_location as location_id FROM product_move Where datetime BETWEEN $first AND $last Have you tried something like this? Best, Oliver Enviado via iPhone Em 21/02/2013, às 08:20 PM, denero team escreveu: > Hi, > > Thanks for replying me. yes you are right a

Re: [SQL] need help

2013-02-21 Thread denero team
Hi, Thanks for replying me. yes you are right at some level for my case. but its not what I want. I am explaining you a case by example. Consider following are data in each table Location : id , name, code 1, stock, stock 2, customer, customer 3, asset, asset Product : id, name, code, location

Re: [SQL] need help

2013-02-21 Thread Carlos Chapi
Hello, Maybe this query can help you SELECT p.name, l.name FROM location l INNER JOIN product_move m ON m.source_location = location.id INNER JOIN product p ON m.product_id = p.id WHERE p.id = $product_id AND m.datetime < $given_date ORDER BY datetime DESC LIMIT 1 It will return the name of the

[SQL] need help

2013-02-21 Thread denero team
Hi All, I need some help for my problem. Problem : I have following tables 1. Location : id, name, code 2. Product id, name, code, location ( ref to location table) 2. Product_Move id, product_id ( ref to product table), source_location (ref to location table) , destination_location (

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread Johnny Winn
On Sat, Sep 29, 2012 at 2:28 PM, Victor Sterpu wrote: > This is a way to do it, but things will change if you have many > attributes/object > > SELECT o.*, COALESCE(a1.value, a2.value) > FROM objects AS o > LEFT JOIN attributes AS a1 ON (a1.object_id = o.id) > LEFT JOIN attributes AS a2 ON (a2.ob

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread Victor Sterpu
This is a way to do it, but things will change if you have many attributes/object SELECT o.*, COALESCE(a1.value, a2.value) FROM objects AS o LEFT JOIN attributes AS a1 ON (a1.object_id = o.id) LEFT JOIN attributes AS a2 ON (a2.object_id = 0); On 29.09.2012 19:02, Andreas wrote: Hi, asume I've

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread David Johnston
On Sep 29, 2012, at 12:02, Andreas wrote: > Hi, > > asume I've got 2 tables > > objects ( id int, name text ) > attributes ( object_id int, value int ) > > attributes has a default entry with object_id = 0 and some other where > another value should be used. > > e.g. > objects > ( 1, '

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread Samuel Gendler
On Sat, Sep 29, 2012 at 9:02 AM, Andreas wrote: > Hi, > > asume I've got 2 tables > > objects ( id int, name text ) > attributes ( object_id int, value int ) > > attributes has a default entry with object_id = 0 and some other where > another value should be used. > > e.g. > objects > ( 1,

[SQL] Need help with a special JOIN

2012-09-29 Thread Andreas
Hi, asume I've got 2 tables objects ( id int, name text ) attributes ( object_id int, value int ) attributes has a default entry with object_id = 0 and some other where another value should be used. e.g. objects ( 1, 'A' ), ( 2, 'B' ), ( 3, 'C' ) attributes ( 0, 42

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> You seem to be describing a straight reconciliation between two tables. > My > current means of doing this are programmatically but for the simple case > pure SQL should be doable. The main thing is that you have to distinguish > between "duplicate" records first and then match them up: > > Tabl

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> You seem to be describing a straight reconciliation between two tables. > My > current means of doing this are programmatically but for the simple case > pure SQL should be doable. The main thing is that you have to distinguish > between "duplicate" records first and then match them up: > > Tabl

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
gt; > Best, > Oliver > > - Original Message - > From: "Rihad" > To: > Sent: Thursday, June 21, 2012 6:48 PM > Subject: [SQL] Need help building this query > > >> Hi, folks. I currently need to join two tables that lack primary keys, >> and

Re: [SQL] Need help building this query

2012-06-21 Thread Oliver d'Azevedo Christina
:50 PM Subject: Re: [SQL] Need help building this query For matching triples (foo, bar, baz) the date in table B shouldnt always be after any date in table A, as table B contains complete operations? Best, Oliver - Original Message - From: "Rihad" To: Sent: Thursday, J

Re: [SQL] Need help building this query

2012-06-21 Thread Oliver d'Azevedo Christina
For matching triples (foo, bar, baz) the date in table B shouldnt always be after any date in table A, as table B contains complete operations? Best, Oliver - Original Message - From: "Rihad" To: Sent: Thursday, June 21, 2012 6:48 PM Subject: [SQL] Need help building

Re: [SQL] Need help building this query

2012-06-21 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Rihad > Sent: Thursday, June 21, 2012 1:49 PM > To: pgsql-sql@postgresql.org > Subject: [SQL] Need help building this query > > Hi, folks. I cu

[SQL] Need help building this query

2012-06-21 Thread Rihad
Hi, folks. I currently need to join two tables that lack primary keys, and columns used to distinguish each record can be duplicated. I need to build statistics over the data in those tables. Consider this: TableA: row 1: foo: 123, bar: 456, baz: 789, amount: 10.99, date_of_op: date row 2: foo

Re: [SQL] Need help in grouping records

2012-05-20 Thread Andreas
Am 20.05.2012 05:04, schrieb Jasen Betts: On 2012-05-19, Andreas wrote: Hi, I'm trying to fight against double entries in tables. I got as far as I can find similar records with trigram string matching. If I do this with a table compared to itself I get something like this: id_a, id_b 3, 5

Re: [SQL] Need help in grouping records

2012-05-19 Thread Jasen Betts
On 2012-05-19, Andreas wrote: > Hi, > > I'm trying to fight against double entries in tables. > I got as far as I can find similar records with trigram string matching. > If I do this with a table compared to itself I get something like this: > > id_a, id_b > 3, 5 > 3, 7 > 5, 3 > 5, 7 > 7,

[SQL] Need help in grouping records

2012-05-19 Thread Andreas
Hi, I'm trying to fight against double entries in tables. I got as far as I can find similar records with trigram string matching. If I do this with a table compared to itself I get something like this: id_a, id_b 3, 5 3, 7 5, 3 5, 7 7, 3 7, 5 11, 13 13, 11 so the records with t

Re: [SQL] need help with import

2012-02-15 Thread Raj Mathur (राज माथुर)
On Thursday 16 Feb 2012, Andreas wrote: > Hi > I get CSV files to import. > Th structure is like this. > main part, sub part > Could be like this > > A, a1 > A, a2 > A, a3 > B, b1 > B, b2 > > The database has a table for main_part and one for sub_part. > The relation needs to be n:m so there is a

Re: [SQL] need help with import

2012-02-15 Thread David Johnston
12 8:03 PM >> To: pgsql-sql@postgresql.org >> Subject: [SQL] need help with import >> >> Hi >> I get CSV files to import. >> Th structure is like this. >> main part, sub part >> Could be like this >> >> A, a1 >> A, a2 >> A, a3 >>

Re: [SQL] need help with import

2012-02-15 Thread Andreas
Am 16.02.2012 02:13, schrieb David Johnston: -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Andreas Sent: Wednesday, February 15, 2012 8:03 PM To: pgsql-sql@postgresql.org Subject: [SQL] need help with import Hi I get CSV

Re: [SQL] need help with import

2012-02-15 Thread David Johnston
-Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Andreas Sent: Wednesday, February 15, 2012 8:03 PM To: pgsql-sql@postgresql.org Subject: [SQL] need help with import Hi I get CSV files to import. Th structure is like this. main

[SQL] need help with import

2012-02-15 Thread Andreas
Hi I get CSV files to import. Th structure is like this. main part, sub part Could be like this A, a1 A, a2 A, a3 B, b1 B, b2 The database has a table for main_part and one for sub_part. The relation needs to be n:m so there is a relation table that holds ( main_id, sub_id ). The 2 primary key

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Edgardo Portal
On 2011-06-09, Andreas wrote: > Am 09.06.2011 18:20, schrieb Richard Broersma: >> On Thu, Jun 9, 2011 at 6:43 AM, Andreas wrote: >> >>> I have a log-table that stores events of users and projects like this >>> ( user_id integer, project_id integer, ts timestamp, event_type integer ) >>> >>> I nee

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Kevin Crain
Try this: select user_id, project_id, date_trunc, sum(sum) FROM (select user_id, project_id, date_trunc('day', ts), SUM(duration) FROM (select user_id, project_id, a.ts, ((SELECT MIN(b.ts) FROM log b WHERE b.ts>a.ts AND (date_trunc('day',a.ts)=date_trunc('day',b.ts)))-a.ts) AS duration from log a

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Andreas
Am 09.06.2011 18:20, schrieb Richard Broersma: On Thu, Jun 9, 2011 at 6:43 AM, Andreas wrote: I have a log-table that stores events of users and projects like this ( user_id integer, project_id integer, ts timestamp, event_type integer ) I need an aggregated list of worktime per user, per pro

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Richard Broersma
On Thu, Jun 9, 2011 at 6:43 AM, Andreas wrote: > I have a log-table that stores events of users and projects like this > ( user_id integer, project_id integer, ts timestamp, event_type integer ) > > I need an aggregated list of worktime per user, per project, per day. > > The users can switch pro

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Andreas
an user cannot be in more than one project at the time? If so, can'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 tha

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

[SQL] need help with some aggregation magic

2011-06-09 Thread Andreas
hi, I have a log-table that stores events of users and projects like this ( user_id integer, project_id integer, ts timestamp, event_type integer ) I need an aggregated list of worktime per user, per project, per day. The users can switch projects during the day so I can't work this out with mi

Re: [SQL] Need help with plpgsql function.

2010-11-14 Thread Pavel Stehule
2010/11/14 Adrian Klaver : > On Saturday 13 November 2010 11:15:51 pm Pavel Stehule wrote: > >> > } >> >> Hello >> >> you can use a RETURN QUERY statement - some like >> >> CREATE OR REPLACE FUNCTION foo(IN i int, OUT a int, OUT b int) >> RETURNS SETOF RECORD AS $$ >> BEGIN >>   IF i = 1 THEN >>  

Re: [SQL] Need help with plpgsql function.

2010-11-14 Thread Adrian Klaver
On Saturday 13 November 2010 11:15:51 pm Pavel Stehule wrote: > > } > > Hello > > you can use a RETURN QUERY statement - some like > > CREATE OR REPLACE FUNCTION foo(IN i int, OUT a int, OUT b int) > RETURNS SETOF RECORD AS $$ > BEGIN > IF i = 1 THEN > RETURN QUERY SELECT 10,20 UNION ALL SEL

Re: [SQL] Need help with plpgsql function.

2010-11-13 Thread Pavel Stehule
2010/11/14 berelith : > > Hi, > > I'm creating the function on a postgres 8.2 server. > I would like the function to accept half a dozen varied parameters (varchars > and timestamps). > The first parameter will determine which one of the 6 different select > queries that function is going to run. >

[SQL] Need help with plpgsql function.

2010-11-13 Thread berelith
Hi, I'm creating the function on a postgres 8.2 server. I would like the function to accept half a dozen varied parameters (varchars and timestamps). The first parameter will determine which one of the 6 different select queries that function is going to run. The function will return all the row

Re: [SQL] Need help on update.

2010-10-21 Thread Nicholas I
that was amazing, it worked thanks a lot. -Nicholas I On Thu, Oct 21, 2010 at 1:40 PM, Richard Huxton wrote: > On 21/10/10 08:43, Nicholas I wrote: > >> Hi, >> >> there are two tables, table1 and table2, each having same column name >> called sn_no,name. i want to update table1 names with table

Re: [SQL] Need help on update.

2010-10-21 Thread Richard Huxton
On 21/10/10 08:43, Nicholas I wrote: Hi, there are two tables, table1 and table2, each having same column name called sn_no,name. i want to update table1 names with table2 where sn_no are same. select * from table1; sn_no | name ---+--- 1 | ramnad 2 | bangalore 3

[SQL] Need help on update.

2010-10-21 Thread Nicholas I
Hi, there are two tables, table1 and table2, each having same column name called sn_no,name. i want to update table1 names with table2 where sn_no are same. select * from table1; sn_no | name ---+--- 1 | ramnad 2 | bangalore 3 | chennai select * from table2; sn_no

Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-31 Thread Yogi Dwianandono Rizkiadi
t(integer) OWNER TO postgres; -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Pavel Stehule Sent: 30 Agustus 2009 22:56 To: Tom Lane Cc: Yogi Rizkiadi; pgsql-sql@postgresql.org Subject: Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT

Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-30 Thread Pavel Stehule
2009/8/30 Tom Lane : > Pavel Stehule writes: >> COPY in plpgsql are not allowed. > > I think it will work if you use an EXECUTE. > >                        regards, tom lane > I didn't test it. regards Pavel Stehule -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes

Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-30 Thread Tom Lane
Pavel Stehule writes: > COPY in plpgsql are not allowed. I think it will work if you use an EXECUTE. regards, tom lane -- 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] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-29 Thread Pavel Stehule
Hello COPY in plpgsql are not allowed. regards Pavel Stehule 2009/8/30 Yogi Rizkiadi : > Hi admin, i'm gie from indonesia > > i wanna ask you how to make a dynamic output file from command COPY TO ? > > i have tried this : > > BEGIN > i:=0; > j:=10; > WHILE i < j LOOP > COPY (SELECT * FROM count

[SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-29 Thread Yogi Rizkiadi
Hi admin, i'm gie from indonesia i wanna ask you how to make a dynamic output file from command COPY TO ? i have tried this : BEGIN i:=0; j:=10; WHILE i < j LOOP COPY (SELECT * FROM country) TO '/usr/proj/' || i || '.txt'; // need attention here END LOOP; RETURN; END

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread Rob Sargent
if you want topics listed which don't yet have messages try select t.id, t.topic, m.id, m.message from topics t left join messages m on m.topic = t.id; On Fri, May 22, 2009 at 8:47 AM, James Kitambara wrote: > Dear Richard Ekblom, > > I think Mr. Adrian Klaver gave you the solution. Mine is the

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread Oliveiros Cristina
pgsql-sql@postgresql.org Sent: Friday, May 22, 2009 3:47 PM Subject: Re: [SQL] Need help combining 2 tables together Dear Richard Ekblom, I think Mr. Adrian Klaver gave you the solution. Mine is the similar solution SELECT message.id,topic.topic,message.me

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread James Kitambara
Dear Richard Ekblom, I think Mr. Adrian Klaver gave you the solution. Mine is the similar solution SELECT message.id,topic.topic,message.message FROM topics, messages WHERE message.topic=topic.id order by message.id;   After executing this query you will get the following: id |  top

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread Adrian Klaver
On Friday 22 May 2009 6:48:43 am Richard Ekblom wrote: > Hello > > I have frequently encountered the need of combining two tables into one. > First, please take a look at the following table setups... > > CREATE TABLE topics ( >id SERIAL PRIMARY KEY, >topic TEXT NOT NULL > ); > > CREATE TAB

[SQL] Need help combining 2 tables together

2009-05-22 Thread Richard Ekblom
Hello I have frequently encountered the need of combining two tables into one. First, please take a look at the following table setups... CREATE TABLE topics ( id SERIAL PRIMARY KEY, topic TEXT NOT NULL ); CREATE TABLE messages ( id SERIAL PRIMARY KEY, topic INTEGER REFERENCES topics(

Re: [SQL] need help in building a query

2008-11-08 Thread Devil™ Dhuvader
> > > Try: > > bdteste=# SELECT o1.user_id, o1.order_id, '>= 500' AS cond FROM Orders o1 > bdteste-# WHERE (SELECT sum(o2.amount_paid) FROM Orders o2 WHERE > o2.user_id = o1.user_id AND o2.order_id > o1.order_id) < 500 AND > bdteste-#(SELECT sum(o2.amount_paid) FROM Orders o2 WHERE > o2.us

Re: [SQL] need help in building a query

2008-11-08 Thread Devil™ Dhuvader
yes, I am picking up the specific transaction (order_id) so that I can pickup the create_timestamp and sort it descending. that will list me those users who did transaction more than 500 in the least time. then I can give discount for top 10 users expected output: user_id, create_timestamp(desc) wi

Re: [SQL] need help in building a query

2008-11-07 Thread Frank Bax
Devil™ Dhuvader wrote: its like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the entry that has sum > $500. If there is some user who didnt even make 500 till now in my shop return the first date of transaction/order . ex: Orders(order_id,

Resp.: [SQL] need help in building a query

2008-11-07 Thread Osvaldo Kussama
2008/11/7, Devil™ Dhuvader <[EMAIL PROTECTED]>: > its like sum up entries of each user in order table backwards (i.e from last > entry to the first) and find the entry that has sum > $500. > If there is some user who didnt even make 500 till now in my shop return the > first date of transaction/ord

Re: [SQL] need help in building a query

2008-11-07 Thread Devil™ Dhuvader
its like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the entry that has sum > $500. If there is some user who didnt even make 500 till now in my shop return the first date of transaction/order. ex: Orders(order_id, user_id, amount_paid, create_t

Re: [SQL] need help in building a query

2008-11-06 Thread Harold A. Giménez Ch.
I personally would help if I understood what you need. I'm sure others feel the same way. Provide DDL, sample data, and expected result of the query. Maybe you'll have better luck... On Thu, Nov 6, 2008 at 11:15 AM, Devil™ Dhuvader <[EMAIL PROTECTED]>wrote: > none can help me? > > On Tue, Nov 4,

Re: [SQL] need help in building a query

2008-11-06 Thread Devil™ Dhuvader
none can help me? On Tue, Nov 4, 2008 at 9:08 PM, Devil™ Dhuvader <[EMAIL PROTECTED]> wrote: > hi, > I need some help in creating a sql. > the problem is as below. > > assume that: > I am a store keeper > and I have the list of customer(user_id) transactions in my order table. > schema: Orders(or

[SQL] need help in building a query

2008-11-04 Thread Devil™ Dhuvader
hi, I need some help in creating a sql. the problem is as below. assume that: I am a store keeper and I have the list of customer(user_id) transactions in my order table. schema: Orders(order_id, user_id, amount_paid, create_timestamp) I want to give discount of 10% for the customer who made orde

Re: [SQL] need help

2007-12-26 Thread Richard Broersma Jr
--- On Wed, 12/26/07, A. Wiryawan <[EMAIL PROTECTED]> wrote: > niwey do you have any e-books abour postgresql to be > shared, if you don't mind please sent me Sure, There are lots of books on the Postgresql site: http://www.postgresql.org/docs/8.2/interactive/index.html http://www.postgresql.or

Re: [SQL] need help

2007-12-26 Thread Richard Broersma Jr
--- On Wed, 12/26/07, A. Wiryawan <[EMAIL PROTECTED]> wrote: > From: A. Wiryawan <[EMAIL PROTECTED]> > Subject: [SQL] need help > To: pgsql-sql@postgresql.org > Date: Wednesday, December 26, 2007, 11:19 AM > is there any one online in yahoo messenger right now..? I am

[SQL] need help

2007-12-26 Thread A. Wiryawan
is there any one online in yahoo messenger right now..? Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Re: [SQL] Need help with CASE statement in Function

2007-10-03 Thread Richard Broersma Jr
--- Hengky Lie <[EMAIL PROTECTED]> wrote: > My Question is : How to make argument 4 optional ? When IS NULL the function > will show all transaction between date $1 and $2 and product ID=$3 Could you simply overload your function by having two functions? One with arguement 4 and one without? R

Re: [SQL] Need help with CASE statement in Function

2007-10-03 Thread Dawid Kuroczko
On 10/3/07, Hengky Lie <[EMAIL PROTECTED]> wrote: > Dear friends, > I am a new user to postgreSQL and really need help to solve my "stupid ?" > problem. > > I have created function with 4 arguments like this : > > CREATE OR REPLACE FUNCTION "public"."fHistoryCard" (begdate date, enddate > date, Pr

[SQL] Need help with CASE statement in Function

2007-10-03 Thread Hengky Lie
Dear friends, I am a new user to postgreSQL and really need help to solve my "stupid ?" problem. I have created function with 4 arguments like this : CREATE OR REPLACE FUNCTION "public"."fHistoryCard" (begdate date, enddate date, ProductID varchar, storeID varchar) RETURNS SETOF "publi

Re: [SQL] need help

2007-05-14 Thread Aaron Bono
On 5/14/07, Penchalaiah P. <[EMAIL PROTECTED]> wrote: Hi … Create table cdano_nya(cdano int4,nyano int4) … I created this table and then I inserted some values to this( 234576,86)… Now when I am updating this table .. its not updating ..query is continuously running…

Re: [SQL] need help

2007-05-14 Thread Ashish Karalkar
Anyone else is using this table simulteniously? With Regards Ashish... - Original Message - From: Penchalaiah P. To: pgsql-sql@postgresql.org Sent: Monday, May 14, 2007 12:20 PM Subject: [SQL] need help Hi . Create table cdano_nya(cdano int4,nyano int4

Re: [SQL] need help

2007-05-14 Thread Andrej Ricnik-Bay
On 5/14/07, Penchalaiah P. <[EMAIL PROTECTED]> wrote: Any one can help in this Operating system? Postgres version? How does psql behave? Anything in the logs? Cheers, Andrej ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner wi

[SQL] need help

2007-05-13 Thread Penchalaiah P.
Hi ... Create table cdano_nya(cdano int4,nyano int4) ... I created this table and then I inserted some values to this( 234576,86)... Now when I am updating this table .. its not updating ..query is continuously running... When I am stopping query its

Re: [SQL] Need help: Find dirty rows, Update, Delete SQL

2006-02-20 Thread Patrick JACQUOT
Janning Vygen wrote: Am Samstag, 18. Februar 2006 18:41 schrieb [EMAIL PROTECTED]: Hello, I need a bit of help with some SQL. I have two tables, call them Page and Bookmark. Each row in Page can have many Bookmarks pointing to it, and they are joined via a FK (Page.id = Bookmark.page_id).

Re: [SQL] Need help: Find dirty rows, Update, Delete SQL

2006-02-19 Thread Janning Vygen
Am Samstag, 18. Februar 2006 18:41 schrieb [EMAIL PROTECTED]: > Hello, > > I need a bit of help with some SQL. > I have two tables, call them Page and Bookmark. > Each row in Page can have many Bookmarks pointing to it, and > they are joined via a FK (Page.id = Bookmark.page_id). > > Page has a 'ur

[SQL] Need help: Find dirty rows, Update, Delete SQL

2006-02-18 Thread ogjunk-pgjedan
Hello, I need a bit of help with some SQL. I have two tables, call them Page and Bookmark. Each row in Page can have many Bookmarks pointing to it, and they are joined via a FK (Page.id = Bookmark.page_id). Page has a 'url' column: Page.url, which has a unique index on it. My Page.url column got

[SQL] need help (not anymore)

2005-12-06 Thread Jenny
I run the VACUUM as you suggested, but still no response from the server. So, I decided to DROP the database. I got a message that the database is being used. I closed every application that accessing it. But, the message remains. I checked the server processes (ps -ax). There were lots of 'UPDAT

[SQL] need help

2005-12-06 Thread Jenny
I'm running PostgreSQL 8.0.3 on i686-pc-linux-gnu (Fedora Core 2). I've been dealing with Psql for over than 2 years now, but I've never had this case before. I have a table that has about 20 rows in it. Table "public.s_apotik" Column | Type| Modifi

Re: [SQL] Need help with 'unique parents' constraint

2005-09-14 Thread Daryl Richter
Leif B. Kristensen wrote: On Sunday 11 September 2005 16:04, Greg Sabino Mullane wrote: Not just old-fashioned, it's the biological law! (among homo sapiens anyway). I'd approach this with a trigger, as you can do complex checks and get back nice customized error messages. A sample script foll

Re: [SQL] Need help with `unique parents` constraint

2005-09-12 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Thank you for an excellent answer. I think I will have to study your > code for a while. But is it such a bad idea to have a separate column > for the primary key here? I see that there are two schools on this, > with diametrically opposed views.

Re: [SQL] Need help with 'unique parents' constraint

2005-09-12 Thread Leif B. Kristensen
On Sunday 11 September 2005 16:04, Greg Sabino Mullane wrote: > Not just old-fashioned, it's the biological law! (among homo sapiens > anyway). I'd approach this with a trigger, as you can do complex > checks and get back nice customized error messages. A sample script > follows. Hard to tell with

Re: [SQL] Need help with 'unique parents' constraint

2005-09-11 Thread John Hasler
Greg Sabino Mullane writes: > Not just old-fashioned, [having only one mother is] the biological law! I see you aren't up on current research. -- John Hasler [EMAIL PROTECTED] Elmwood, WI USA ---(end of broadcast)--- TIP 4: Have you searched our l

Re: [SQL] Need help with 'unique parents' constraint

2005-09-11 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Now, I want to ensure that each person_id can be assigned only one > father (gender=1) and one mother (gender=2). (Yes, this is old- > fashioned, but I'm working with 18th century people). How do I do it? Not just old-fashioned, it's the biologica

Re: [SQL] Need help with 'unique parents' constraint

2005-09-11 Thread Leif B. Kristensen
On Sunday 11 September 2005 14:24, Leif B. Kristensen wrote: > ALTER TABLE relations ADD CONSTRAINT non_unique_father > CHECK (NOT EXISTS > (SELECT persons.person_id, relations.parent_fk > FROM persons AS P, relations AS R > WHERE R.parent_fk = P.person_id >

[SQL] Need help with 'unique parents' constraint

2005-09-11 Thread Leif B. Kristensen
This message has also been posted to comp.databases. I've got a problem that I can't quite wrap my head around, about adding a constraint to my PostgreSQL genealogy database. If somebody are interested, I've written some thoughts on the general design at . I

[SQL] Need help form inherits

2004-08-01 Thread Patrice OLIVER
Hello everybody, I would like to use inherits between 2 tables : user(login,password) and studiant(firstname, lastname, email) these tables are created like this : create table user ( login varchar(15) not null primary key, password varchar(32)); create table studiant ( firstname varchar(35), lastn

[SQL] need help with os x objects into a db

2004-06-03 Thread Theodore Petrosky
Does anyone here have experience with OS X and storing NSData objects in a postgresql db? I have archived data that I want to store in a bytea column. I just can not get it to work. I hope there is a kind soul that can help Ted __ Do you Yahoo!? Yahoo! Finan

Re: [SQL] Need Help : Query problem

2003-11-19 Thread Michael Glaesemann
On Wednesday, November 19, 2003, at 10:26 AM, Abdul Wahab Dahalan wrote: How do I write a query so that I can get a result as below [ select only a record/s with same kk and kj but different pngk. For example here I've 3 records with same kk=01,kj=01 but diff pngk=a,b,c and 2 records with same kk

[SQL] Need Help : Query problem

2003-11-18 Thread Abdul Wahab Dahalan
Hi Everybody! If I've a table like below kk | kj | pngk | vote ++--+-- 01 | 01 | a| 10 01 | 01 | b| 10 01 | 01 | c| 10 01 | 02 | a| 10 01 | 02 | b| 10 01 | 03 | a| 10 How do I write a query so that I can get a result as below [ select only a reco

Re: [SQL] Need Help

2003-11-13 Thread Bruno Wolff III
On Fri, Nov 14, 2003 at 09:04:47 +0800, Abdul Wahab Dahalan <[EMAIL PROTECTED]> wrote: > Hi! > > If I've a table like this > > kk kj pngk vote > 01 02 a 12 > 01 02 b 10 > 01 03 c 5 > > and I want to have a

[SQL] Need Help

2003-11-13 Thread Abdul Wahab Dahalan
Hi! If I've a table like this kk kj pngk vote 01 02 a 12 01 02 b 10 01 03 c 5 and I want to have a query so that it give me a result as below. The condition is for each record with the same kk and kj but di

Re: [SQL] Need help with complex query

2003-07-09 Thread Yasir Malik
. I hope to continue to learn from professionals like you. Thank you so much, Yasir On Wed, 9 Jul 2003, Christoph Haller wrote: > Date: Wed, 09 Jul 2003 16:46:43 +0200 > From: Christoph Haller <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Re: [SQL] Need help with compl

  1   2   >