SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sum results
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

maggie21620
Starting Member

USA
27 Posts

Posted - 02/24/2014 :  10:15:18  Show Profile  Reply with Quote
good Morning Folks
You guys always have great suggestions. So i have a qry that i run where it shows all ppv ordered for a particular customer and i want the results to show a total column for that customer. Any help is greatly appreciated:


SELECT DISTINCT
adHock.dbo.PPVVINCE$.Corps, adHock.dbo.PPVVINCE$.House, adHock.dbo.PPVVINCE$.Cust,
CONVERT (VARCHAR (10),IDST_EVENT_ORDERS.ORDATE,101) ORDERDATE,
CONVERT (CHAR(5), IDST_EVENT_ORDERS.ORTIME,108) ORDERTIME,
IDST_EVENT_ORDERS.EVWMIN,
IDST_EVENT_ORDERS.EVTDES,
IDST_EVENT_ORDERS.EVENT_OUTLETS,
IDST_EVENT_ORDERS.VIEWTYPE,
IDST_EVENT_ORDERS.LAST_UPDATE_DATE,
IDST_EVENT_ORDERS.PRICE
FROM adHock.dbo.PPVVINCE$ INNER JOIN
infoddp.dbo.IDST_EVENT_ORDERS ON adHock.dbo.PPVVINCE$.Corps = IDST_EVENT_ORDERS.ACCTCORP AND
adHock.dbo.PPVVINCE$.House = IDST_EVENT_ORDERS.HOUSE AND adHock.dbo.PPVVINCE$.Cust = infoddp.dbo.IDST_EVENT_ORDERS.CUST
WHERE IDST_EVENT_ORDERS.ORDATE BETWEEN @start AND @end



---------------

it worked fine dates and all but they now want only to see the totals for each customer, uhhhhhhhh so this is the other one:

SELECT DISTINCT adHock.dbo.PPVVINCE$.Corps, adHock.dbo.PPVVINCE$.House, adHock.dbo.PPVVINCE$.Cust, IDST_74_CUSTOMER.PPV_TOTAL
FROM adHock.dbo.PPVVINCE$ INNER JOIN
IDST_74_CUSTOMER ON adHock.dbo.PPVVINCE$.Corps = IDST_74_CUSTOMER.ACCTCORP AND
adHock.dbo.PPVVINCE$.House = IDST_74_CUSTOMER.HOUSE AND adHock.dbo.PPVVINCE$.Cust = IDST_74_CUSTOMER.CUST
WHERE IDST_74_CUSTOMER.ACCTCORP IN (@CORPS) AND IDST_74_CUSTOMER.HOUSE IN (@HOUSE)
--WHERE IDST_74_CUSTOMER.PPV_TOTAL BETWEEN @start AND @end

only issue is it only gives me the most recent total,

any suggestions would be greatly apprecaited.

none

maunishq
Yak Posting Veteran

Canada
71 Posts

Posted - 02/24/2014 :  11:55:26  Show Profile  Reply with Quote
Do a SUM on the total column and put rest of the columns in the GROUP BY clause.
e.g. SUM(total_Column) and GROUP BY column_1, Column_2, etc...


!!_(M)_!!
Go to Top of Page

maggie21620
Starting Member

USA
27 Posts

Posted - 02/24/2014 :  14:01:17  Show Profile  Reply with Quote
thank you so much I will try that.

none
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000