concatnate string field using group


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: concatnate string field using group

  1. #1
    Pat Guest

    concatnate string field using group


    Hi,

    I am trying to select a list of customer names order a certain product,

    select SUM(customer.name) from customerOrder group by productID/

    apparently SUM only works for a number field, does anybody know if
    there is a way to concatenate all the customer together for a particular
    product? Or it's not doable in a simple SQL sentence.

    Thanks
    Pat

  2. #2
    Vassilis Tatlis Guest

    Re: concatnate string field using group


    Try the following query.
    It does not concatenate customer names. It returns all customer names in
    one row.

    TRANSFORM Max(CustOrder.CustName) AS [TheValue]
    SELECT CustOrder.ProductID
    FROM CustOrder
    GROUP BY CustOrder.ProductID
    ORDER BY CustOrder.ProductID
    PIVOT CustOrder.CustNameID;

    "Pat" <pwang@uclink.berkeley.edu> wrote:
    >
    >Hi,
    >
    >I am trying to select a list of customer names order a certain product,
    >
    >select SUM(customer.name) from customerOrder group by productID/
    >
    >apparently SUM only works for a number field, does anybody know if
    >there is a way to concatenate all the customer together for a particular
    >product? Or it's not doable in a simple SQL sentence.
    >
    >Thanks
    >Pat



  3. #3
    mike Guest

    Re: concatnate string field using group


    Pat,

    you could try selecting them into a cursor, and then move through the cursor
    adding the name field to a varchar variable.... a bit like a loop in vb

    mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center