I am trying to get a sum of the dollar amount for each term for each
customer. Unfortunately, the same value for sum is returned, so I thinkt
hat I have my query wrong. My query looks like this:
SELECT sales.name, sales.terms, t_order_term.order_term_description,
SUM(sales.prodamt) AS TheSum
FROM sales CROSS JOIN dbo.t_order_term
WHERE (NOT (dbo.sales.terms = N'12 , 24, 35, 39, 50, 57, 62'))
GROUP BY dbosales.name, dbo.t_order_term.order_term_description,
dbo.sales.terms
ORDER BY dbo.sales.name
My results look like this:
Customer1 30 988787.23
Customer1 60 988787.23
Customer2 30 78234.78
Customer2 60 78234.78
What am I doing wrong?
Thanks.
JoshuaDarn inner join problems...
I figured it out. Thanks.
Joshua
"Joshua Campbell" <Joshua.Campbell@.nospam.nospam> wrote in message
news:uEhyPS8LFHA.3064@.TK2MSFTNGP12.phx.gbl...
> I am trying to get a sum of the dollar amount for each term for each
> customer. Unfortunately, the same value for sum is returned, so I thinkt
> hat I have my query wrong. My query looks like this:
> SELECT sales.name, sales.terms, t_order_term.order_term_description,
> SUM(sales.prodamt) AS TheSum
> FROM sales CROSS JOIN dbo.t_order_term
> WHERE (NOT (dbo.sales.terms = N'12 , 24, 35, 39, 50, 57, 62'))
> GROUP BY dbosales.name, dbo.t_order_term.order_term_description,
> dbo.sales.terms
> ORDER BY dbo.sales.name
> My results look like this:
> Customer1 30 988787.23
> Customer1 60 988787.23
> Customer2 30 78234.78
> Customer2 60 78234.78
> What am I doing wrong?
> Thanks.
> Joshua
>
>|||Perhaps something more like this?
SELECT S1.name, S1.terms, O1.order_term_descri=ADption,
SUM(S1.prod_amt) AS prod_amt_total
FROM Sales AS S1, OrderTerms AS O1
WHERE S1.terms NOT IN (12, 24, 35, 39, 50, 57, 62)
GROUP BY S1.name, S1.terms, O1.order_term_de=ADscription ;
Surely you do not have a CSV list in a column!
No comments:
Post a Comment