Need to add a new (non aggregate item) in a SQL st

Results 1 to 2 of 2

Thread: Need to add a new (non aggregate item) in a SQL st

  1. #1
    Join Date
    Dec 1969

    Default Need to add a new (non aggregate item) in a SQL st

    Help!!<BR><BR>Can someone please help me in figuring this out.<BR><BR>I have an SQL statement that produce aggregate data and it is group by product name. Now the problem is that I have to add another item to the SQL statement that is non aggregate data.<BR><BR>Example SQL<BR><BR>SELECT item.productNM, count(item.stockcode) num_items, sum(item.adjustedprice) price_sum, avg(item.adjustedprice) price_avg, max(item.adjustedprice) price_max, min(item.adjustedprice) price_min, sum(item.qty) qty_sum, avg(item.qty) qty_avg, max(item.qty) qty_max, min(item.qty) qty_min FROM orders receipt, orderdetails item WHERE receipt.orderid = item.orderid and CONVERT(CHAR(10), orderDateTime, 101) = CONVERT(CHAR(10),cast(@date as datetime), 101) GROUP BY productNM<BR><BR>I want to add "item.tagitem" that displays all the additional item that comes with the productNM. How should i go about it?<BR><BR>Thxs in advance<BR><BR>Al<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Need to add a new (non aggregate item) in a SQ

    Add item.tagname into your group by and select clause...<BR><BR>SELECT item.productNM, item.tagname, count(item.stockcode) <BR>...<BR>GROUP BY productNM, item.tagname<BR><BR><BR> <BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts