Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## [Alzabo] Calculations in SQL functions

 [Alzabo] Calculations in SQL functions From: Bernd Petrovitsch - 2005-05-04 10:10:01 ```Given a table with the columns "x bigint" and "y bigint". How can I formulate the following: ---- snip ---- SELECT packageinstid, round(x::NUMERIC / 1024 / 1024, 1), round(y::NUMERIC / 1024 / 1024, 1) FROM table ORDER BY round(x::NUMERIC / 1024 / 1024, 1), round(y::NUMERIC / 1024 / 1024, 1); ---- snip ---- The following works but how get I the divisions (and type conversion) in there? ---- snip ---- order_by => [ Alzabo::SQLMaker::PostgreSQL::ROUND(\$table->column('x'), 1), Alzabo::SQLMaker::PostgreSQL::ROUND(\$table->column('y'), 1), ] ---- snip ---- Something like Alzabo::SQLMaker::PostgreSQL::ROUND( [ \$table->column('x'), '/', 1024, '/', 1024 ], 1) didn't work. Bernd -- Firmix Software GmbH http://www.firmix.at/ mobil: +43 664 4416156 fax: +43 1 7890849-55 Embedded Linux Development and Services ```

 [Alzabo] Calculations in SQL functions From: Bernd Petrovitsch - 2005-05-04 10:10:01 ```Given a table with the columns "x bigint" and "y bigint". How can I formulate the following: ---- snip ---- SELECT packageinstid, round(x::NUMERIC / 1024 / 1024, 1), round(y::NUMERIC / 1024 / 1024, 1) FROM table ORDER BY round(x::NUMERIC / 1024 / 1024, 1), round(y::NUMERIC / 1024 / 1024, 1); ---- snip ---- The following works but how get I the divisions (and type conversion) in there? ---- snip ---- order_by => [ Alzabo::SQLMaker::PostgreSQL::ROUND(\$table->column('x'), 1), Alzabo::SQLMaker::PostgreSQL::ROUND(\$table->column('y'), 1), ] ---- snip ---- Something like Alzabo::SQLMaker::PostgreSQL::ROUND( [ \$table->column('x'), '/', 1024, '/', 1024 ], 1) didn't work. Bernd -- Firmix Software GmbH http://www.firmix.at/ mobil: +43 664 4416156 fax: +43 1 7890849-55 Embedded Linux Development and Services ```
 Re: [Alzabo] Calculations in SQL functions From: Dave Rolsky - 2005-05-04 15:29:12 ```On Wed, 4 May 2005, Bernd Petrovitsch wrote: > Given a table with the columns "x bigint" and "y bigint". > How can I formulate the following: > ---- snip ---- > SELECT packageinstid, > round(x::NUMERIC / 1024 / 1024, 1), > round(y::NUMERIC / 1024 / 1024, 1) > FROM table > ORDER BY round(x::NUMERIC / 1024 / 1024, 1), > round(y::NUMERIC / 1024 / 1024, 1); > ---- snip ---- > The following works but how get I the divisions (and type conversion) in > there? > ---- snip ---- > order_by => > [ Alzabo::SQLMaker::PostgreSQL::ROUND(\$table->column('x'), 1), > Alzabo::SQLMaker::PostgreSQL::ROUND(\$table->column('y'), 1), > ] > ---- snip ---- > Something like > Alzabo::SQLMaker::PostgreSQL::ROUND( > [ \$table->column('x'), '/', 1024, '/', 1024 ], 1) > didn't work. Unfortunately there's no support for this ATM. Suggestions for syntax are welcome. I could implement the one above easily enough, I think. -dave /*=================================================== VegGuide.Org http://www.BookIRead.com Your guide to all that's veg. My book blog ===================================================*/ ```
 Re: [Alzabo] Calculations in SQL functions From: Bernd Petrovitsch - 2005-05-04 22:29:32 ```On Wed, 2005-05-04 at 10:29 -0500, Dave Rolsky wrote: > On Wed, 4 May 2005, Bernd Petrovitsch wrote: [...] > > Something like > > Alzabo::SQLMaker::PostgreSQL::ROUND( > > [ \$table->column('x'), '/', 1024, '/', 1024 ], 1) > > didn't work. > > Unfortunately there's no support for this ATM. Suggestions for syntax are Is something wrong with the array above? That way it should even be nestable. > welcome. I could implement the one above easily enough, I think. Bernd -- Firmix Software GmbH http://www.firmix.at/ mobil: +43 664 4416156 fax: +43 1 7890849-55 Embedded Linux Development and Services ```
 Re: [Alzabo] Calculations in SQL functions From: Dave Rolsky - 2005-05-25 15:35:40 ```On Thu, 5 May 2005, Bernd Petrovitsch wrote: > On Wed, 2005-05-04 at 10:29 -0500, Dave Rolsky wrote: >> On Wed, 4 May 2005, Bernd Petrovitsch wrote: > [...] >>> Something like >>> Alzabo::SQLMaker::PostgreSQL::ROUND( >>> [ \$table->column('x'), '/', 1024, '/', 1024 ], 1) >>> didn't work. >> >> Unfortunately there's no support for this ATM. Suggestions for syntax are > > Is something wrong with the array above? > That way it should even be nestable. Yeah, that seems reasonable. You could make it look nice(r) like this: [ \$table->column('x'), qw( / 1024 / 1024 ), 1 ] -dave /*=================================================== VegGuide.Org http://www.BookIRead.com Your guide to all that's veg. My book blog ===================================================*/ ```