Re: [SQL] SELECT max(time) group by problem

2009-07-30 Thread nha
Hello, Le 30/07/09 11:38, Heigo Niilop a écrit : > hi, > > I have table > > CREATE TABLE table > ( > id integer NOT NULL, > timest timestamp with time zone NOT NULL, > db_time timestamp with time zone NOT NULL DEFAULT now(), > "values" text[], > CONSTRAINT table_pkey PRIMARY KEY (id, t

Re: [SQL] Show CAS, USD first; the left ordered by currency name

2009-07-30 Thread sergey kapustin
...order by currency not in('USD', 'AND', 'CAD'); this condition will be avaluated as FALSE for USD, AND and CAD, and as TRUE for all other currencies. When the records are sorted the "false" are placed on the top because false wrote: > Good morning, > > I have a currency table (code, description

Re: [SQL] Show CAS, USD first; the left ordered by currency name

2009-07-30 Thread Andreas Kretschmer
Emi Lu wrote: > Good morning, > > I have a currency table (code, description). > > Example values: > ADF | Andorran Franc > ... ... > ANG | NL Antillian Guilder > AON | Angolan New Kwanza > AUD | Australian Dollar > AWG | Aruban Florin > BBD | Barbados Dollar > USD | US Dollar > CAD | Ca

[SQL] Show CAS, USD first; the left ordered by currency name

2009-07-30 Thread Emi Lu
Good morning, I have a currency table (code, description). Example values: ADF | Andorran Franc ... ... ANG | NL Antillian Guilder AON | Angolan New Kwanza AUD | Australian Dollar AWG | Aruban Florin BBD | Barbados Dollar USD | US Dollar CAD | Canadian Dollar Is there a way I can query

Re: [SQL] SQL report

2009-07-30 Thread Steve Crawford
wkipj...@gmail.com wrote: I have the following senario. I have a tracking system. The system will record the status of an object regularly, all the status records are stored in one table. And it will keep a history of maximum 1000 status record for each object it tracks. The maximum objects t

Re: [SQL] Foreign keys and fixed values...

2009-07-30 Thread Daryl Richter
Hi- On Jul 29, 2009, at 4:16 PM, Kjell Rune Skaaraas wrote: Hello, I'm having a problem using foreign keys, or at least in a way i find good. Basicly I have a table I wish to use as a foreign key with lookup "id" and "code", like: 1,a 1,b 1,c 2,a 2,d I have of course an UNIQUE on (id,c

Re: [SQL] Tweak sql result set... ?

2009-07-30 Thread Rob Sargent
I agree. All clients issue the same sql and deal with it as they will. The psql client for example can format the results in various ways (pset variations etc). Your client(s) need(s) to interpret their identical results differently. Doesn't seem to me to be the job of SQL? Jasmin Dizdarev

Re: [SQL] SQL report

2009-07-30 Thread Rob Sargent
I would be curious to know the performance curve for let's say 20K, 40K , 60K, 80K, 100K records. And what sort of indexing you have, whether or not it's clustered, re-built and so on. One could envision partitioning the status table such that recent records were grouped together (on the assu

Re: [SQL] Tweak sql result set... ?

2009-07-30 Thread Tim Landscheidt
(anonymous) wrote: >> > Any ideas on how to achieve this? I would like to let the original sql >> > code stay original. I can prepare postgres before executing the sql if >> > this makes it easier to acheive the goal >> Have a look at CREATE RULE. > Ok, you mean I could create a rule for the tab

[SQL] SELECT max(time) group by problem

2009-07-30 Thread Heigo Niilop
hi, I have table CREATE TABLE table ( id integer NOT NULL, timest timestamp with time zone NOT NULL, db_time timestamp with time zone NOT NULL DEFAULT now(), "values" text[], CONSTRAINT table_pkey PRIMARY KEY (id, timest) ) „id“ have foreign key with table1 and when I t

Re: [SQL] Tweak sql result set... ?

2009-07-30 Thread Jasmin Dizdarevic
i think jasen is thinking of manipulating the result set in your programming enviroment not in the database. btw from the point of "clean programming" it's a bad idea to integrate html-elements directly into your database quereis. you're mixing data layer and design layer. what do you mean with so