StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Aggregate Query and Custom FieldsExpand / Collapse
Author
Message
Posted 08/14/2008 9:45:17 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 10:49:34 AM
Posts: 478, Visits: 1,969
I have a CustomersBO that has several custom fields to reflect order totals for the typical calendar breakdowns - week-, month-, quarter-, and year-to-date.  I have a stored procedure that summarizes these totals for me.  I use that stored procedure to fill my BO.  Here is a snippet of the sql script:


SELECT    
 Customers.*,
 (
 SELECT
  SUM(SalesOrderDetails.quantity * SalesOrderDetails.unitprice) AS wtdorders
 FROM
  SalesOrderDetails
  LEFT OUTER JOIN SalesOrderMaster ON SalesOrderMaster.orderindex = SalesOrderDetails.orderindex 
 WHERE
  (SalesOrderMaster.divisionindex = @div)
  AND SalesOrderMaster.custindex = Customers.CustIndex
  AND (SalesOrderMaster.orderdate BETWEEN @start_week AND @enddate)
  AS WTDOrders,
 ...
 ... other lines for mtd, qtd, and ytd here
 ...
FROM        
 CustomerMaster Customers
WHERE
 Customers.Status = 1
 AND Customers.inactive = 0

The line I marked in red is my suspected line.  The query runs, but I am getting a null value for every customer (or zero, if utilize the ISNULL function), no matter what dates or division I use.  The subquery works great on its own when I use a specific customer index.  I thought that I had used this kind of approach to retrieving sum values before, but for some reason I cannot figure out why this does not work.  Can anyone point out where my error may be in the query?

Thanks!
Bill

Post #18489
Posted 08/14/2008 10:11:36 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 10:49:34 AM
Posts: 478, Visits: 1,969

After wrestling too long with this query, I decided to start whacking every criteria and get it to work without any limitations (date, division or otherwise).  In the end, I discovered that my statusindex was keyed in wrong (not 1, but 3).  The query works and it works like a charm!!  It all comes down to the "good data in, good data out" principle.

Sorry to bother y'all with this one.  Have a great day!


Bill

Post #18490
Posted 08/14/2008 10:19:22 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 6:26:12 PM
Posts: 4,901, Visits: 4,887
LOL...we have all been there...even this morning   Glad you got it working!
Post #18491
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 7:57pm

Powered by InstantForum.NET v4.1.4 © 2009
Execution: 0.109. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.