Re: [SQL] select and as doubt

2006-01-14 Thread Tom Lane
=?ISO-8859-1?Q?Alexandre_Gon=E7alves_Jacarand=E1?= <[EMAIL PROTECTED]> writes: > It's possible to make an SELECT inside an AS clause ? No. You could try building the query as a string. regards, tom lane ---(end of broadcast)---

[SQL] select and as doubt

2006-01-14 Thread Alexandre Gonçalves Jacarandá
Hello folks!!! I've a question that could be very strange: It's possible to make an SELECT inside an AS clause ? ex.: select student_id, subject_name_id, grade as (select subject_name from subject_names) from grades; The wy is that i've a table with subject names and another with name_id and grad

Re: [SQL] psql client: technique for applying default values to :variables?

2006-01-14 Thread Michael Glaesemann
On Jan 14, 2006, at 23:54 , Jeff Boes wrote: Tony Wasson wrote: Stuff like this works for me in a SQL file \set edate 'CURRENT_DATE::DATE' SELECT * FROM some_table WHERE update_date = :edate; Sure, but that was not my question. I want to be able to set the variable on the command

Re: [SQL] psql client: technique for applying default values to :variables?

2006-01-14 Thread Jeff Boes
Tony Wasson wrote: On 1/11/06, Jeff Boes <[EMAIL PROTECTED]> wrote: Stumped: is there any way to set up default values for psql variables within the .SQL file itself? Obviously, I can do something like: $ psql -f my_script -v MYVAR=${myvar:-mydefault} but I would prefer to have t

Re: [SQL] Another orderby problem

2006-01-14 Thread Alan Chandler
On Saturday 14 January 2006 13:09, A. Kretschmer wrote: > am 14.01.2006, um 13:02:48 + mailte Alan Chandler folgendes: > > select name, id, transaction.date as tdate, description, amount > > from account join transaction on name=dst where name ='Sarah' > > order by tdate asc; > > > > name |

Re: [SQL] Another orderby problem

2006-01-14 Thread D'Arcy J.M. Cain
On Sat, 14 Jan 2006 13:02:48 + Alan Chandler <[EMAIL PROTECTED]> wrote: > select name, id, transaction.date as tdate, description, -amount as amount > from account left join transaction on name=src where name = 'Sarah' > union > select name, id, transaction.date as tdate, description, amount >

Re: [SQL] Another orderby problem

2006-01-14 Thread A. Kretschmer
am 14.01.2006, um 13:02:48 + mailte Alan Chandler folgendes: > select name, id, transaction.date as tdate, description, amount > from account join transaction on name=dst where name ='Sarah' > order by tdate asc; > > name | id | tdate|description| amount > ---+

[SQL] Another orderby problem

2006-01-14 Thread Alan Chandler
Just joined the list and have seen in the archive the thread on orderby. But mine seems different. I have a finanancial application with account and transactions which go between accounts (source and destination) but in which one either can be null. I am attempting to read an account and sort