Link to home
Start Free TrialLog in
Avatar of jayseena
jayseenaFlag for United Arab Emirates

asked on

Script Case - SQL Query

Hi,
I am using Scriptcase for a project.

I have table as attached
 User generated image
In a grid I have the query "onRecord"


// Check for record
$check_sql = "SELECT sum(recip_export), sum(recip_import), sum(recip_origin_export), sum(recip_mm)"
           . " FROM recip"
           . " WHERE recip_supplier = '" . {recip.recip_supplier} . "'";

sc_lookup(rs, $check_sql);

if (isset({rs[0][0]}))     // Row found
{
    {Exportation} = {rs[0][0]};
    {Import} = {rs[0][1]};
        {Exportation_Origin} = {rs[0][2]};
            {move_manament} = {rs[0][3]};
 
}
else     // No row found
{
    {other_field} = '';
    {other_region} = '';
}

Open in new window


The resulting grid is
User generated image
Notice the value 105 and 150 are repeated everywhere.

When I make SQL Query externally I get the result I wanted
SELECT recip.recip_supplier, sum(recip.recip_export), sum(recip.recip_import)
FROM recip GROUP BY recip.recip_supplier

Open in new window


User generated image
Where I am getting wrong. Could some one throw some light, please.

Thanks  
ASKER CERTIFIED SOLUTION
Avatar of ropenner
ropenner
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jayseena

ASKER

I did that earlier and there was a clash between a group function within SC.
However I managed to avoid that and grouped it in the query, as you suggested
Thanks for your help.