Solved

Script Case - SQL Query

Posted on 2011-09-27
2
2,798 Views
Last Modified: 2012-08-13
Hi,
I am using Scriptcase for a project.

I have table as attached
 DB Table
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
Resulting Table
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


Query Result
Where I am getting wrong. Could some one throw some light, please.

Thanks  
0
Comment
Question by:jayseena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
ropenner earned 500 total points
ID: 36715531
GROUP BY recip.recip_supplier

is missing from your code
0
 

Author Closing Comment

by:jayseena
ID: 36718454
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.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
remote mysql 8 40
converting integer data type to time data type in sql 4 48
Mysql how to execute a commands file 5 33
mysql qry 1 25
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime is disastrous for companies and can lead to major hits on a brand, reputation, an…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question