[SQL] Insert problem

2008-03-09 Thread A. R. Van Hook
I have a table where some of the entries of should have been posted to the wrong cusid and item#: cusid | item# | 1747 | 149 | 9251 : Jonathon Krinke ... 1747 | 150 | 10071 : Lindsey Steele 1747 | 151 | 10187 : Lindsay Stapley ... 1747 | 152 | 10188 : Amanda Gou

[SQL] wrong answer

2007-08-21 Thread A. R. Van Hook
I have a simple (and incorrect queuer) that gives the wrong answer. Can someone show me the correct syntax? t "select sum(s.ref), r.value, s.ref from registry as s left join referralkey as r on (s.ref = r.cd) group by s.ref, r.value order by r.value, s.ref" sum | value | ref --+

Re: [SQL] join problem

2007-06-24 Thread A. R. Van Hook
Works great. Can you enlighten me as why the deposit is divided by the number of rows? thanks Ragnar wrote: On lau, 2007-06-23 at 04:15 -0500, A. R. Van Hook wrote: Ragnar wrote: On fim, 2007-06-21 at 08:46 -0500, A. R. Van Hook wrote: If I try an inclusive query using the

Re: [SQL] join problem

2007-06-23 Thread A. R. Van Hook
What is the correct query??? thanks Ragnar wrote: On fim, 2007-06-21 at 08:46 -0500, A. R. Van Hook wrote: if I query for the total deposit using select sum(deposit) from invoice where cusid = 2128" I also get 1179.24, also the correct amount If I try an inclusive query

[SQL] join problem

2007-06-21 Thread A. R. Van Hook
I have three tables relating to purchases invoice - transaction data (customer id, deposit. etc) invoiceitems - purachace items detail cai - customer data if I query for the total charges using select sum(rowtot + tax) from invoiceitems where ivid in (select ivi

[SQL] join problem

2007-06-13 Thread A. R. Van Hook
I have join problem: "select i.ivid, v.eventdate, v.deposit, v.invdate, cai.db, sum(i.tax) as tax, sum(i.tax + i.rowtot) as totalP, (sum(i.tax + i.rowtot) - v.deposit) as balance from invoice v left outer join

[SQL] or function

2006-12-30 Thread A. R. Van Hook
I have been trying to do an 'or' function such that if a field value is zero then use 1 as a multiplier: "select sum((1 | i.count) * s.cost) as COST seems to work ok when the value is 0 but I get the wrong value is i.count in not zero stid | count | tot | ldate| pkcnt | status | cost ---

[SQL] Time interval sums

2006-10-02 Thread A. R. Van Hook
How does one sum interval sums? the following does not work: select sum(stop-start::interval) as total from startstop where sid= 545 and 2006 = date_part('year', day) and 9 = date_part('month', day) however se

Re: [SQL] date array

2006-04-24 Thread A. R. Van Hook
additional questions. On Sun, Apr 23, 2006 at 13:21:49 -0500, "A. R. Van Hook" <[EMAIL PROTECTED]> wrote: I am running 8.1.2, what can I do in the mean time? You could build from source using HEAD. (This is probably not a good idea for a production system.) You could restr

[SQL] date array

2006-04-23 Thread A. R. Van Hook
How do you add null values to a date array? update dattable set insDate = '{04/12/2006,'null'}<-- doesn't work update dattable set insDate= '{04/12/2006,null}' <-- doesn't work update dattable set insDate= '{04/12/2006,''}' <-- doesn't work the table field is defined as insDate d

[SQL] new rule syntax?

2006-02-05 Thread A. R. Van Hook
I have two tables defined as: checks (ckidint NOT null PRIMARY KEY, payto text, notes text, ckdate date, printed int default 0, tdate timestamp not null) checkitems

[SQL] sysid

2005-11-23 Thread A. R. Van Hook
It seems that in 8.1.0 we can no longer set the SYSID when adding users and groups. i.e template1=# create role hooker sysid 1345; NOTICE: SYSID can no longer be specified I have lots of code that depends on the actual group and user number. Is there a way to set the user and group number? tha

[SQL] max question

2005-04-12 Thread A. R. Van Hook
I have the following in a table: oid | citkey | contby | contdate | abcontinue | ccdate -++--+++ 5774835 | 04-0594703 | ||| 5775325 | 04-0594703 | Attorney | 04/06/2005 | 6 | 03