Re: [SQL] problem with sql

2003-10-25 Thread Michael Glaesmann
Hi Adam,

On Monday, Oct 20, 2003, at 01:56 Asia/Tokyo, Adaƛ wrote:
status. I made a query using LAST and GROUP BY to select last order 
for each customer and I wanted to use it in UPDATE query, but it seems 
to be impossible.
I don't believe PostgreSQL has a built-in function similar to MS 
Access' LAST. Something like the following might work for you:

SELECT DISTINCT ON (client) client, order_number, order_date FROM 
orders ORDER BY order_date desc

You might have to change the DISTINCT ON terms to match what you want. 
Check the docs for usage of DISTINCT ON.

Also, I've heard it's quite easy to write a custom function to do what 
you want using CREATE FUNCTION. Haven't done it myself.

Hope it helps.

Michael

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] naming conventions constraint

2003-10-25 Thread Julian North
thats just what i needed to know.

many many thanks!


j.

-Original Message-
From: Rod Taylor [mailto:[EMAIL PROTECTED]
Sent: 24 October 2003 19:01
To: Julian North
Cc: [EMAIL PROTECTED]
Subject: Re: naming conventions constraint


rbt=# create table bob_is(your_uncle integer, constraint
"bob_is#your_uncle" check(true));
CREATE TABLE
rbt=# \d bob_is
  Table "public.bob_is"
   Column   |  Type   | Modifiers
+-+---
 your_uncle | integer |
Check constraints:
"bob_is#your_uncle" CHECK true


You need to quote strings which contain special characters.

On Thu, 2003-10-23 at 16:30, Julian North wrote:
> I'm at the very beginning of working with postgres.
>
> The aim is to replace / build a number of very large and very complex
> database currently residing in Oracle, MSSQL and Informix.
>
> In order to coordinate across a medium size DBA team I instituted a
standard
> constraint naming convention suitable for the above 3 platforms.
>
> For example a foreign key would be FK_table#reftable#column.
>
> Unfortunately I don't appear to be able to use it with postgres.
>
> This is because I can't use the # character in constraint names.
>
> Does anybody have any suggestions as to an alternative that is also a
single
> char? (I'm limited to 30 chars cos of oracle and manyof the current names
at
> the limit).
>
> Any help appreciated,
>
>
>
> Julian.
>
>
>
> ---(end of broadcast)---
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
>


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]