?
Solved

Script Case - SQL Query

Posted on 2011-09-27
2
Medium Priority
?
2,997 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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 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