Re: [SQL] Compare the resulta of a count sql into bash

2011-01-26 Thread Scott Marlowe
On Wed, Jan 26, 2011 at 10:07 AM, manuel antonio ochoa wrote: > > Hello, > I have the next : > > COUNTONE=`/var/lib/pgsql/bin/./psql -U 'Thor'   -d princlocal -p 5432 -h > 192.170.1.82  -c "select count(*) from monterrey.${NOMBRETB}"` > COUNTTWO=`/var/lib/pgsql/bin/./psql -U 'Thor'   -dprinclocal

Re: [SQL] Compare the resulta of a count sql into bash

2011-01-26 Thread Josh Kupershmidt
On Wed, Jan 26, 2011 at 12:07 PM, manuel antonio ochoa wrote: > > Hello, > I have the next : > > COUNTONE=`/var/lib/pgsql/bin/./psql -U 'Thor'   -d princlocal -p 5432 -h > 192.170.1.82  -c "select count(*) from monterrey.${NOMBRETB}"` > COUNTTWO=`/var/lib/pgsql/bin/./psql -U 'Thor'   -dprinclocal

Re: [SQL] check files .backup

2011-01-26 Thread Craig Ringer
On 01/25/2011 11:14 PM, manuel antonio ochoa wrote: I would like it complete and not truncated? That it hasn't been modified since being originally written? OK. First, check the exit code from pg_backup so you detect any failures. The exit code is reported by the shell on UNIX systems in the

[SQL] Compare the resulta of a count sql into bash

2011-01-26 Thread manuel antonio ochoa
Hello, I have the next : COUNTONE=`/var/lib/pgsql/bin/./psql -U 'Thor' -d princlocal -p 5432 -h 192.170.1.82 -c "select count(*) from monterrey.${NOMBRETB}"` COUNTTWO=`/var/lib/pgsql/bin/./psql -U 'Thor' -dprinclocal -p 5432 -h 192.170.1.82 -c "select count(*) from monterrey.$nombre where re

Re: [SQL] how to get row number in select query

2011-01-26 Thread Oliveiros d'Azevedo Cristina
If it is to order in ascendent fashion by, say, lname, one possibility would be SELECT COUNT(b.*) as row_number, a.lname,a.gname FROM "Table1" a, "Table2" b WHERE a.lname >= b.lname GROUP BY a.lname,a.gname ORDER BY row_number If you want to order by gname just change the WHERE clause according

Re: [SQL] how to get row number in select query

2011-01-26 Thread Oliveiros d'Azevedo Cristina
Hi, Lu Ying. How do you define which row is #1 ? And #2 ? E.g. Ordered by lname? Or gname...? Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Wednesday, January 26, 2011 4:11 PM Subject: [SQL] how to get row number in select query Good morning, For postgresql 8.3

[SQL] how to get row number in select query

2011-01-26 Thread Emi Lu
Good morning, For postgresql 8.3, what is the system method/key word to get row number please? E.g., == lname1 gname1 lname2 gname2 lname3 gname3 .. I'd like to get 1 lname1 gname1 2 lname2 gname2 3 lname3 gname3 ... ... Something like select row_number?, lnam