Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
maggie21620
Starting Member
27 Posts |
Posted - 2014-02-24 : 10:15:18
|
good Morning FolksYou 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.PRICEFROM 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.CUSTWHERE 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_TOTALFROM 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.CUSTWHERE IDST_74_CUSTOMER.ACCTCORP IN (@CORPS) AND IDST_74_CUSTOMER.HOUSE IN (@HOUSE) --WHERE IDST_74_CUSTOMER.PPV_TOTAL BETWEEN @start AND @endonly issue is it only gives me the most recent total,any suggestions would be greatly apprecaited.none |
|
maunishq
Yak Posting Veteran
71 Posts |
Posted - 2014-02-24 : 11:55:26
|
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)_!! |
|
|
maggie21620
Starting Member
27 Posts |
Posted - 2014-02-24 : 14:01:17
|
thank you so much I will try that.none |
|
|
|
|
|
|
|