internetworkers AT lists.ibiblio.org
Subject: Internetworkers: http://www.ibiblio.org/internetworkers/
List archive
- From: "Michael Best" <mbest AT dasya.com>
- To: "'Internetworkers: http://www.ibiblio.org/internetworkers/'" <internetworkers AT lists.ibiblio.org>
- Subject: Re: [internetworkers] SQL Help?
- Date: Tue, 26 Feb 2008 11:57:53 -1000
I usually solve this by using subqueries. Most databases let you nest
queries. Doing so allows you to reference calculated columns in the outer
query:
SELECT iteration, label, read_ops, read_data, read_latency, read_ops *
read_data AS concurrency from (SELECT ... ) q1;
You can use the IFNULL function if you want to avoid NULL values:
IFNULL(columnname, 0) will return 0 if columnname is NULL.
-- Michael Best
> -----Original Message-----
> From: internetworkers-bounces AT lists.ibiblio.org
> [mailto:internetworkers-bounces AT lists.ibiblio.org] On Behalf
> Of Scott Russell
> Sent: Monday, February 25, 2008 5:23 PM
> To: Internetworkers: http://www.ibiblio.org/internetworkers/
> Subject: Re: [internetworkers] SQL Help?
>
>
> On Mon, 2008-02-25 at 18:47 -0500, Scott Russell wrote:
> > On Mon, 2008-02-25 at 16:41 -0500, Ilan Volow wrote:
> > > I'm a PostgreSQL guy, so take my educated guess with a grain of
> > > salt, but you might want to try this just to see if it works:
> >
> > Much appreciated. I'll take a look at it...
> >
>
> FYI, You're suggestion worked fine. I'm not entirely
> convinced I'm doing this sanely still, but it does work.
>
> I also do this to calculate a read_size column which has the
> formula of (read_bytes/read_ops = read_size). Note that
> read_ops could be 0 which would yield a NULL in the read_size
> column. To avoid that, I use a nested IF!
>
> IF(SUM(IF(latx_stats_data.statname = 'read_ops', `statval`,
> 0)), (SUM(IF(latx_stats_data.statname = 'read_data',
> `statval`, 0)) / SUM(IF(latx_stats_data.statname =
> 'read_ops', `statval`, 0))), 0) AS 'read_size'
>
> I have to do this with several columns. I wonder if should
> read up on stored procedures...
>
> --
> Scott <catfather AT donpoo.net>
> AIM: BlueCame1
>
> ---
> Come and play at the InterNetWorkers Web site!
> http://www.ibiblio.org/internetworkers/
> You are currently subscribed to InterNetWorkers mailing list
> To unsubscribe visit
> http://lists.ibiblio.org/mailman/listinfo/internetworkers
>
>
-
[internetworkers] SQL Help?,
Scott Russell, 02/24/2008
-
Re: [internetworkers] SQL Help?,
Ilan Volow, 02/25/2008
-
Re: [internetworkers] SQL Help?,
Scott Russell, 02/25/2008
-
Re: [internetworkers] SQL Help?,
Scott Russell, 02/25/2008
- Re: [internetworkers] SQL Help?, Ilan Volow, 02/26/2008
- Re: [internetworkers] SQL Help?, Michael Best, 02/26/2008
-
Re: [internetworkers] SQL Help?,
Scott Russell, 02/25/2008
-
Re: [internetworkers] SQL Help?,
Scott Russell, 02/25/2008
-
Re: [internetworkers] SQL Help?,
Ilan Volow, 02/25/2008
Archive powered by MHonArc 2.6.24.