Bacula-users

Re: [Bacula-users] bconsole query for calculating client 7days utilization

2009-12-18 06:41:21
Subject: Re: [Bacula-users] bconsole query for calculating client 7days utilization
From: Dan Langille <dan AT langille DOT org>
To: vishal veerkar <vishalveerkar AT gmail DOT com>
Date: Fri, 18 Dec 2009 06:37:36 -0500
vishal veerkar wrote:
> After trying some combination with other queries finally i got the break 
> through...below query gives the output for All clients utilization in GB 
> for specified time window...this may helpful for others
> 
> :List storage used by client and pool after specified time window
> *Enter Start time in YYYY-MM-DD HH:MM:SS format:
> *Enter End time in YYYY-MM-DD HH:MM:SS format:
> SELECT Client.Name AS Client, Pool.Name as Pool,
>    sum(Job.JobFiles) as Files, sum(Job.JobBytes)/(1024*1024*1024) as 
> TotalSizeGb
>  FROM Client, Job, Pool
>  WHERE Job.ClientID = Client.ClientID and Job.PoolID = Pool.PoolID
>  AND JobStatus='T'
>  AND Job.StartTime >= '%1'
>  AND Job.StartTime <= '%2'
>  GROUP by Client.ClientID
>  ORDER by Client.Name;

Please note, the above is not valid SQL

bacula-#  FROM Client, Job, Pool
bacula-#  WHERE Job.ClientID = Client.ClientID and Job.PoolID = Pool.PoolID
bacula-#  AND JobStatus='T'
bacula-#  AND Job.StartTime >= '2009-12-01'
bacula-#  AND Job.StartTime <= '2009-12-17'
bacula-#  GROUP by Client.ClientID
bacula-#  ORDER by Client.Name;
ERROR:  column "client.name" must appear in the GROUP BY clause or be 
used in an aggregate function
bacula=#


This is valid SQL:

SELECT Client.Name AS Client, Pool.Name as Pool,
    sum(Job.JobFiles) as Files, sum(Job.JobBytes)/(1024*1024*1024) as 
TotalSizeGb
  FROM Client, Job, Pool
  WHERE Job.ClientID = Client.ClientID and Job.PoolID = Pool.PoolID
  AND JobStatus='T'
  AND Job.StartTime >= '2009-12-01'
  AND Job.StartTime <= '2009-12-17'
  GROUP by Client.Name, Pool.Name
  ORDER by Client.Name;

I will be interested to see if you get the same results with both queries

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users