Re: [SQL] avoid select expens_expr(col) like unneccessary calculations

2003-07-07 Thread scott.marlowe
On 8 Jul 2003, Markus Bertheau wrote: > Hi, > > when you have > select expensive_expression(column), * from table offset 20 limit 40 > > can you somehow save the cost for the first 20 calculations of > expensive_expression? Might a functional or partial index work here?

Re: [SQL] avoid select expens_expr(col) like unneccessary calculations

2003-07-07 Thread Stephan Szabo
On 8 Jul 2003, Markus Bertheau wrote: > when you have > select expensive_expression(column), * from table offset 20 limit 40 > > can you somehow save the cost for the first 20 calculations of > expensive_expression? Right now the only way I can think of that might work is to push the offset/limit

[SQL] avoid select expens_expr(col) like unneccessary calculations

2003-07-07 Thread Markus Bertheau
Hi, when you have select expensive_expression(column), * from table offset 20 limit 40 can you somehow save the cost for the first 20 calculations of expensive_expression? -- Markus Bertheau. Berlin, Berlin. Germany. ---(end of broadcast)--- TIP

Re: [SQL] sort for ranking

2003-07-07 Thread scott.marlowe
I'm gonna guess you stored your ranking as a "text" field, but now you'd like to treat it like an int / numeric. While it would be better to go ahead and convert it, you can always cast it: select * from table order by textfield::int; On Mon, 7 Jul 2003, Andreas Schmitz wrote: > > Hello *, >

Re: [SQL] sort for ranking

2003-07-07 Thread Jean-Luc Lachance
Andreas, try select sum_user,nextval('tipp_eval_seq')-1 as ranking from ( select user_sum from tbl_sums order by user_sum desc) as ss; JLL Andreas Schmitz wrote: > > Hello *, > > I have a little problem that confuses me. We are gathering values from a table > as a sum to insert them into

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread markus brosch
> > but how are you searching through your table with sql, when your SELECT > > is against a collection of different elements (e.g. Array of Strings, > > which should fit on one column and return all records which fit) > > Are the 'a', 'b', etc... fixed or generated on the fly? I'm not sure > th

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread Stephan Szabo
On 7 Jul 2003, markus brosch wrote: > I was searching the archive and was wondering why nobody asked this > strange(!) question (or I've not found it?): > > "What is the max allowed length of a sql statement or query?" AFAIR in recent versions it's effectively limited only by resources (how much

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread markus brosch
On Mon, 2003-07-07 at 18:13, [EMAIL PROTECTED] wrote: > Well i DO NOT know the exact limit. > May be someone else can answer it accurately. > > But you could produce the list within IN using a subselect > that again depends on the exact problem. > Maybe anybody knows how many? Anyway: My exact

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread Rod Taylor
> Could be a solution?! > The question is - how long could the IN be? I'm not sure about IN specifically, but I know you can do: SELECT * FROM table WHERE col = '<1GB long file>'; It tends not to be friendly for Ram though :) signature.asc Description: This is a digitally signed message part

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread mallah
> On Mon, 2003-07-07 at 17:57, [EMAIL PROTECTED] wrote: >> Depending on ur original problem EXISTS or IN may be usable >> EXISTS is efficient and IN can be used efficiently in 7.4 version of >> postgresql > > Could be a solution?! > The question is - how long could the IN be? > > I mean, if I write

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread markus brosch
On Mon, 2003-07-07 at 17:57, [EMAIL PROTECTED] wrote: > Depending on ur original problem EXISTS or IN may be usable > EXISTS is efficient and IN can be used efficiently in 7.4 version > of postgresql Could be a solution?! The question is - how long could the IN be? I mean, if I write something l

[SQL] Need help with complex query

2003-07-07 Thread Yasir Malik
Suppose I have a relation called sales with the following schema: sales-Schema = (cust, prod, mn, dy, yr, quant, st) An instance of the relation would look something like this: custprodmn dy yr quant st == == == = == Knuth Milk02

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread mallah
Depending on ur original problem EXISTS or IN may be usable EXISTS is efficient and IN can be used efficiently in 7.4 version of postgresql regds mallah. > Hi All! > > I was searching the archive and was wondering why nobody asked this > strange(!) question (or I've not found it?): > > "What

[SQL] max length of sql select statement ?

2003-07-07 Thread markus brosch
Hi All! I was searching the archive and was wondering why nobody asked this strange(!) question (or I've not found it?): "What is the max allowed length of a sql statement or query?" I want to combine hundrets or thousands 'OR' within a select statement. Possible or not (e.g: SELECT * FROM table

Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Richard Huxton
On Monday 07 Jul 2003 4:10 pm, Gary Stainburn wrote: > On Monday 07 Jul 2003 3:34 pm, Richard Huxton wrote: > > Don't do "select *" do "select field_a,field_b..." - the * doesn't just > > refer to the locos table. > > Sorry if I didn't make myself plain enough, but I had > > create view loco_dets a

Re: [SQL] Database Upgrade scripts (AKA Conditional SQL execution)

2003-07-07 Thread Joe Conway
Richard Rowell wrote: Can I accomplish this with postgresql without involving an external process (like say perl)? I guess I could put the upgrade stuff into PL/SQL functions and just drop the functions when I'm done, but I was hoping for something a little "cleaner". There is no way (currently at

Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Gary Stainburn
On Monday 07 Jul 2003 3:34 pm, Richard Huxton wrote: > On Monday 07 Jul 2003 2:12 pm, Gary Stainburn wrote: > > I've managed to get the view I wanted by using sub-selects - as shown > > below, but I now have the 'lid' field showing in the resulting view three > > times (as lid, lnid and lnaid). Ho

Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Richard Huxton
On Monday 07 Jul 2003 2:12 pm, Gary Stainburn wrote: > > I've managed to get the view I wanted by using sub-selects - as shown > below, but I now have the 'lid' field showing in the resulting view three > times (as lid, lnid and lnaid). How can I remove lnid and lnaid from the > result? > > create

[SQL] sort for ranking

2003-07-07 Thread Andreas Schmitz
Hello *, I have a little problem that confuses me. We are gathering values from a table as a sum to insert them into another table. I also need to get a ranking at insert (i.e. Highest points will get first place and so on). I tried ton invole a sequence to qualify the ranking by select at ins

[SQL] Database Upgrade scripts (AKA Conditional SQL execution)

2003-07-07 Thread Richard Rowell
Moving to Postgres from MS SQL server wherever I can. When writing database upgrade scripts, it is nice to construct the script so it will run correctly even if run twice. In MS-SQL's TSQL I would do something like this: IF( SELECT COUNT(*) FROM sysobjects WHERE name = 'foo' AND type ='U' ) < 1

Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Gary Stainburn
On Monday 07 Jul 2003 1:36 pm, you wrote: > On Monday 07 Jul 2003 1:07 pm, Richard Huxton wrote: > > On Monday 07 Jul 2003 12:40 pm, Gary Stainburn wrote: > > > left outer join > > > (select lnumber from lnumbers) ln on ln.lnid = l.lid and > > > > ^^^

Concat and view - Re: [SQL] create view error

2003-07-07 Thread Gary Stainburn
On Monday 07 Jul 2003 1:07 pm, Richard Huxton wrote: > On Monday 07 Jul 2003 12:40 pm, Gary Stainburn wrote: > > left outer join > > (select lnumber from lnumbers) ln on ln.lnid = l.lid and > > ^^^ ^^^ > > > ERROR: No such attribute or f

Re: [SQL] create view error

2003-07-07 Thread Richard Huxton
On Monday 07 Jul 2003 12:40 pm, Gary Stainburn wrote: > left outer join > (select lnumber from lnumbers) ln on ln.lnid = l.lid and ^^^ ^^^ > ERROR: No such attribute or function ln.lnid Is is this? -- Richard Huxton -

Re: [SQL] create view error

2003-07-07 Thread Achilleus Mantzios
On Mon, 7 Jul 2003, Gary Stainburn wrote: > Hi folks, > > I know I'm missing something blindingly obvious, can someone point it out to > me please. > > create table locos ( -- Locos table - contains details of locos > lid int4 default nextval('loco_lid_seq'::text) unique not

[SQL] create view error

2003-07-07 Thread Gary Stainburn
Hi folks, I know I'm missing something blindingly obvious, can someone point it out to me please. create table locos (-- Locos table - contains details of locos lid int4 default nextval('loco_lid_seq'::text) unique not null, lclass int4 references lclass(lcid),

Re: [SQL] Merge Record in Database(SQL Statement)

2003-07-07 Thread listrec
Not quite sure what the question is Assuming, you would like to normalize the data, I suggest to create 4 tables: create table gpa (id integer primary key,gpa varchar(32) not null unique); create table major (id integer primary key,major varchar(32) not null unique); create table birthplace (

[SQL] Merge Record in Database(SQL Statement)

2003-07-07 Thread Shahbuddin Md Isa
Hai.. How to merge record in database(sql statement) if record same attribute, examples:- Attribute Major Birth_Place GPA Record 1science India excellent Record 2science India excellent Please help me.. _