Re: Query help

2019-01-27 Thread Chuck Martin
On Sun, Jan 27, 2019 at 5:27 PM Chuck Martin wrote: > On Sun, Jan 27, 2019 at 8:07 AM Peter J. Holzer wrote: > >> On 2019-01-26 18:04:23 -0500, Chuck Martin wrote: >> [snip] >> > The idea should be obvious, but to explain, insdatetime is set when a >> new >> > record is created in any table. All

Re: Query help

2019-01-27 Thread Chuck Martin
On Sun, Jan 27, 2019 at 8:07 AM Peter J. Holzer wrote: > On 2019-01-26 18:04:23 -0500, Chuck Martin wrote: > [snip] > > The idea should be obvious, but to explain, insdatetime is set when a new > > record is created in any table. All records in ombcase have a foreign > key to > > status that can'

Re: Query help

2019-01-27 Thread Adrian Klaver
On 1/27/19 1:50 PM, Chuck Martin wrote: Chuck Martin Avondale Software On Sun, Jan 27, 2019 at 2:55 PM Adrian Klaver > wrote: On 1/26/19 3:04 PM, Chuck Martin wrote: [snip] Outline form: 1) If a record is in ombcase it has a status('in a sta

Re: Query help

2019-01-27 Thread Chuck Martin
Chuck Martin Avondale Software On Sun, Jan 27, 2019 at 2:55 PM Adrian Klaver wrote: > On 1/26/19 3:04 PM, Chuck Martin wrote: > [snip] > Outline form: > > 1) If a record is in ombcase it has a status('in a status') by definition. > > From query below you are not looking for just records in omb

Re: Query help

2019-01-27 Thread Adrian Klaver
On 1/26/19 3:04 PM, Chuck Martin wrote: I'm having trouble formulating a query. This is a simplified version of the tables: ombcase case_pkey integer, primary key casename varchar insdatetime timestamp w/o time zone status_fkey integer, foreign key status status_pkey inte

Re: Query help

2019-01-27 Thread Peter J. Holzer
On 2019-01-26 18:04:23 -0500, Chuck Martin wrote: > I'm having trouble formulating a query. This is a simplified version of the > tables: > > ombcase > > case_pkey integer, primary key > casename varchar > insdatetime timestamp w/o time zone > status_fkey integer, foreign key > > sta

Re: Query help

2019-01-26 Thread Charles Martin
On Sat, Jan 26, 2019 at 6:30 PM Ron wrote: > On 1/26/19 5:04 PM, Chuck Martin wrote: > > I'm having trouble formulating a query. This is a simplified version of > the tables: > > ombcase > > case_pkey integer, primary key > casename varchar > insdatetime timestamp w/o time zone > sta

Re: Query help

2019-01-26 Thread Ron
On 1/26/19 5:04 PM, Chuck Martin wrote: I'm having trouble formulating a query. This is a simplified version of the tables: ombcase case_pkey integer, primary key casename varchar insdatetime timestamp w/o time zone status_fkey integer, foreign key status status_pkey inte

Re: Query help

2019-01-01 Thread Adrian Klaver
On 1/1/19 12:05 PM, David G. Johnston wrote: On Tuesday, January 1, 2019, Adrian Klaver > wrote: On 1/1/19 11:26 AM, John W Higgins wrote: with accounts_over_total as ( select accountid from transactions where sum(amount) >= 50 group

Re: Query help

2019-01-01 Thread David G. Johnston
On Tuesday, January 1, 2019, Adrian Klaver wrote: > On 1/1/19 11:26 AM, John W Higgins wrote: >> >> with accounts_over_total as ( >> select accountid from transactions where sum(amount) >= 50 group by >> accountid) >> > > Unfortunately there is a hitch in the above:( > > select p_item_no from pro

Re: Query help

2019-01-01 Thread Adrian Klaver
On 1/1/19 11:26 AM, John W Higgins wrote: On Tue, Jan 1, 2019 at 11:06 AM Chuck Martin > wrote: Sorry if this is too basic a question for this list, but I don't fully get how to use aggregates (sum()) and group-by together. I'm trying to get a list o

Re: Query help

2019-01-01 Thread Adrian Klaver
On 1/1/19 11:05 AM, Chuck Martin wrote: Sorry if this is too basic a question for this list, but I don't fully get how to use aggregates (sum()) and group-by together. I'm trying to get a list of transactions where the total for a given account exceeds a given number. I'm not sure an example is

Re: Query help

2019-01-01 Thread David G. Johnston
On Tuesday, January 1, 2019, David G. Johnston wrote: > On Tuesday, January 1, 2019, Chuck Martin > wrote: > >> results wanted-all transactions where account total >= 50 >> >> id. amount. accountid.name >> 1. 50. 1 bill >> 3. 75.

Re: Query help

2019-01-01 Thread John W Higgins
On Tue, Jan 1, 2019 at 11:06 AM Chuck Martin wrote: > Sorry if this is too basic a question for this list, but I don't fully get > how to use aggregates (sum()) and group-by together. I'm trying to get a > list of transactions where the total for a given account exceeds a given > number. I'm not

RE: Query help

2019-01-01 Thread Scot Kreienkamp
Any columns that aren’t involved in a summary operation (think math type or some other type of summary operation) have to be in the group by statement. From what you show below, I would try something like this (untested): Select accountid,name,sum(amount) from table where sum(amount) >’50’ group