[SQL] Advanced Query

2006-06-01 Thread operationsengineer1
hi all, i posted this problem on the novice thread, but it makes much more sense to post it here, instead. sorry fo rthe double posting, i'll be sure to post advanced SQL questions here in the future. i have the following two tables (trimmed down for simplicity's sake): t_inspect id, inspect_tim

Re: [SQL] Advanced Query

2006-06-01 Thread operationsengineer1
> On Thu, Jun 01, 2006 at 04:09:21PM -0700, > [EMAIL PROTECTED] wrote: > > what i can't seem to do is to get both - a count > of > > the total number of t_inspect_result.inspect_pass > > where the value is true and a total count, by > unique > > t_inspect.id. > > Are you looking for something like

[SQL] Using Query Result in WHERE Clause

2006-06-02 Thread operationsengineer1
hi all, SUMMARY: i want to replace AND t_inspect.inspect_pass = 'f' with a complex query that yields the same result. the complex query is in the form of... SELECT DISTINCT ON (t_inspect.inspect_id) t_inspect_result.inspect_result_pass, t_inspect_result.inspect_result_id FROM t_insp

[SQL] How To Exclude True Values

2006-06-05 Thread operationsengineer1
hi all, how can i exclude true values for this query? http://www.rafb.net/paste/results/obtkGz26.html if i uncomment out --AND t_inspect_result.inspect_result_pass = 'f' it looks for prior falses within an inspect_id and returns it. i want the original result set minus the trues, if poss

Re: [SQL] How To Exclude True Values

2006-06-05 Thread operationsengineer1
> hi all, > > how can i exclude true values for this query? > > http://www.rafb.net/paste/results/obtkGz26.html > > if i uncomment out > > --AND t_inspect_result.inspect_result_pass = 'f' > > it looks for prior falses within an inspect_id and > returns it. i want the original result set

Re: [SQL] How To Exclude True Values

2006-06-05 Thread operationsengineer1
> > hi all, > > > > how can i exclude true values for this query? > > > > http://www.rafb.net/paste/results/obtkGz26.html > > > > if i uncomment out > > > > --AND t_inspect_result.inspect_result_pass = > 'f' > > > > it looks for prior falses within an inspect_id and > > returns it. i wan

Re: [SQL] How To Exclude True Values

2006-06-06 Thread operationsengineer1
> > > how can i exclude true values for this query? > > > > > > http://www.rafb.net/paste/results/obtkGz26.html > > > > > > if i uncomment out > > > > > > --AND t_inspect_result.inspect_result_pass = > 'f' > > > > > > it looks for prior falses within an inspect_id > and > > > returns it.

Re: [SQL] How To Exclude True Values

2006-06-06 Thread operationsengineer1
> > inspect_id, inspect_result_id, > inspect_result_pass, > > inspect_result_timestamp > > 3, 5, f, 2006-06-05 05:00:00 > > 3, 6, t, 2006-06-05 06:00:00 > > 4, 7, f, 2006-06-05 07:00:00 > > *4, 8, f, 2006-06-05 08:00:00* > > the query linked in this post will return 3 > lines... > > > > 1, 2, f >

Re: [SQL] Join issue

2006-06-06 Thread operationsengineer1
> Hi, > > I have one to many (from left to right) > relationships among the below tables > in my database > > user -> house -> contract -> contract status >| > > Also, a single house has a single provider and the > provider has multiple > rates inside the provider_rate table in >

Re: [SQL] How To Exclude True Values

2006-06-06 Thread operationsengineer1
> > an inspection node (each row in t_inspect is an > > inspection node) that has passed can't have a new > > defect added - since it has already passed. > > > > therefore, in the defect entry form, i only want > to > > display those inspection nodes that don't have a > true > > value. by defin

Re: [SQL] Join issue

2006-06-07 Thread operationsengineer1
> Table structures: > > ce_house > > house_id > provider_id > > ce_contract > > contract_id > house_id > contract_term > contract_created > > ce_contract_status > > contract_status_id > contract_id > contract_status > contract_status

Re: [SQL] How To Exclude True Values

2006-06-07 Thread operationsengineer1
--- Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > > Richard, that is the result i would need given > that > > data set. i have to digest this version, though. > > > > should this query be more efficient than the > subquery > > version as the table starts to get large? > > My experience is th

Re: [SQL] How To Exclude True Values

2006-06-07 Thread operationsengineer1
> > yields the following error: > > > > ERROR: schema "a" does not exist > > > > i tried to interpret you query and apply it to my > > case, but, apparently, i didn't too good of a job. > > > > do you see the error? > > Hmmm... That is strange. but according to the > PostgreSQL documentation

Re: [SQL] How To Exclude True Values

2006-06-07 Thread operationsengineer1
> > Richard, > > > > i got the expected rewsults! now i just have to > study > > the query to figure out what it does. -lol- > > > > i tried using AS, but i only did it in one place - > > doh! the error message just moved to the next > place i > > didn't do it. i'll know better next time. > >

[SQL] Refactor Query...

2006-06-12 Thread operationsengineer1
hi all, i'm trying to refactor this query: http://www.rafb.net/paste/results/RnkFWZ46.html i've added notes to make its function a bit more clear. i have trie dto refactor it to get rid of the "distinct on" function, but i've had no luck. due to all the WHERE clauses, i can't figure out how to

Re: [SQL] Refactor Query... SOLVED

2006-06-12 Thread operationsengineer1
--- [EMAIL PROTECTED] wrote: > hi all, > > i'm trying to refactor this query: > > http://www.rafb.net/paste/results/RnkFWZ46.html > > i've added notes to make its function a bit more > clear. i have trie dto refactor it to get rid of > the > "distinct on" function, but i've had no luck. > > d

Re: [SQL] COPY to table with array columns (Longish)

2006-06-13 Thread operationsengineer1
> Not quite... ZKCOST and ZPRECMPL are two completely > different things. They > have no relation except they're both stored in the > SYS table in D3. > > If we put it in a tree: > SYS >| >+- ZKCOST >| \- >| >+- ZPRECMPL >| +- >

Re: [SQL] COPY to table with array columns (Longish)

2006-06-13 Thread operationsengineer1
> > Not quite... ZKCOST and ZPRECMPL are two > completely > > different things. They > > have no relation except they're both stored in the > > SYS table in D3. > > > > If we put it in a tree: > > SYS > > | > > +- ZKCOST > > | \- > > | > > +- ZPRECMPL > > |

[SQL] SQL Technique Question

2006-06-15 Thread operationsengineer1
i frequently join certain tables together in various tables. view the following link for an example: http://www.rafb.net/paste/results/mBvzn950.html is it a good practice to leave this included in the queries, as is, or should i factor it out somehow? if i should factor it, how do i do so? tia

Re: [SQL] SQL Technique Question

2006-06-15 Thread operationsengineer1
> > On Jun 16, 2006, at 5:59 , > <[EMAIL PROTECTED]> wrote: > > > i frequently join certain tables together in > various > > tables. > > > > view the following link for an example: > > > > http://www.rafb.net/paste/results/mBvzn950.html > > > > is it a good practice to leave this included in > th

Re: [SQL] SQL Technique Question

2006-06-15 Thread operationsengineer1
> On Thu, Jun 15, 2006 at 01:59:22PM -0700, > [EMAIL PROTECTED] wrote: > > > > is it a good practice to leave this included in > the > > queries, as is, or should i factor it out somehow? > if > > i should factor it, how do i do so? > > If what you're saying is that these additional > criteria a

[SQL] Problem w/ Join... Using (...) Syntax

2006-06-26 Thread operationsengineer1
how does one apply the JOIN... USING (...) syntax when the primary key and foreign key have different names? JOIN t_employee USING (employee_id) works perfect when the primary and foreign key are both named employee_id. however, it one is named inspector_id and the other employee_id, it doesn't

Re: [SQL] Data Entry and Query forms

2006-06-29 Thread operationsengineer1
> Hi > I am new in PostgreSQL, I have just installed and > created a database, I use MS-SQL 2000 and planning > to Migrate to Open Source. > > PostgreSQL is installed on Linux Redhat Server. > We have 50 Clients PC using WinXP. > > Before continuing our Plans, I need to know how >

Re: [SQL] Alternative to serial primary key

2006-07-06 Thread operationsengineer1
> On 7/6/06, David Clarke <[EMAIL PROTECTED]> wrote: > > > > I posted a couple of weeks back a question > regarding the use of a 100 > > char column as a primary key and the responses > uniformily advised the > > use of a serial column. My concern is that the key > is effectively > > abstract and I

Re: [SQL] Foreign Key: what value?

2006-07-06 Thread operationsengineer1
> Hi, > How to know the value which I must set in the > foreign key field?. I have two > tables: > > > CREATE TABLE AA ( > Id SERIAL PRIMARY KEY, > data char(9) > ); > > CREATE TABLE BB ( > BB_Id integer REFERENCES AA(Id) NOT NULL, > field char(5) > ); > > > > > I i

Re: [SQL] Alternative to serial primary key

2006-07-06 Thread operationsengineer1
> Plus I feel I would be remiss in not > exploring an > alternative to the serial key. why? it is a tried and true method. > I can always > regenerate my primary key > from the data which is impossible with a serial key. why on earth would you need to "regenerate" the primary key? it is used t

Re: [SQL] i have table

2006-10-04 Thread operationsengineer1
--- "Penchalaiah P." <[EMAIL PROTECTED]> wrote: > > Hi ... > > I have one table with 12 fields.. > > > > CREATE TABLE addition_alteration_memo > > ( > > addition_alteration_memo int8 NOT NULL DEFAULT > nextval('addition_alteration_memo_addition_alteration_memo_seq'::regclas > s), > > c

Re: [SQL] Organization of tables

2007-06-15 Thread operationsengineer1
Hi Salman, will this achieve your needs? peptide_table primary_key name (ie, Peptide1, Peptide2) mass fragment_table primary_key name (ie, A, Q, K) link_table primary_key peptide_id fragment_id it gives you easy access to peptide mass and it allows you to link multiple fragm