Gossamer Forum
Quote Reply
Global for summing
Hello!

First of all, I wish everyone here at GT a nice and sunny summer Cool

Now, a question:

I have in my databaze a column "Maximum capacity" (Column Type = INT and Form Names are stored from 1 to 10).

I would like to show the total number of beds - is there some kind of simple global to do that?

That means, I need to show the sum of all the numbers (beds) of all the ads as a total amount.

Many thanks in advance!

EDIT:

Sorry, a small correction - it should calculate only ads that are marked as "I offer accommodation" (Column Name = Rent_or_hire; Column Type = ENUM; Form Names = 1 or 2, 1 is the one who is correct).

Last edited by:

katakombe: Jul 27, 2013, 8:53 AM
Quote Reply
Re: [katakombe] Global for summing In reply to
Should be as simple as:

Code:
sub {
return $DB->table("Links")->select( ['SUM(Maximum_capacity)'], { Rent_or_hire => 1} )->fetchrow;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global for summing In reply to
Perfect as usual ... Smile

Thanks Andy