Group By for columns that are data type text


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Group By for columns that are data type text

  1. #1
    Craig Guest

    Group By for columns that are data type text

    Hi there

    I have a SQL query similar to the following;

    select appnum, sum(assetcost), notes from contracts
    group by appnum, notes

    The notes column is of data type text. This statement fails because columns
    with a data type of text cannot be part of a group by statement. The
    application has been in production for a year so I cannot change the notes
    field to a varchar() data type (nor do I want to, because the client treats
    unlimited notes space as a big plus over their previous application). How
    can I get a Group By statement to work when one of the columns is data type
    text?

    Thanks.



  2. #2
    Craig Guest

    Re: Group By for columns that are data type text

    I should do more research before I post questions. I've just found that I
    can use the cast function to convert the text column to varchar.

    "Craig" <cjewiss.nospam@hotmail.com> wrote in message
    news:3ae626f3@news.devx.com...
    > Hi there
    >
    > I have a SQL query similar to the following;
    >
    > select appnum, sum(assetcost), notes from contracts
    > group by appnum, notes
    >
    > The notes column is of data type text. This statement fails because

    columns
    > with a data type of text cannot be part of a group by statement. The
    > application has been in production for a year so I cannot change the notes
    > field to a varchar() data type (nor do I want to, because the client

    treats
    > unlimited notes space as a big plus over their previous application). How
    > can I get a Group By statement to work when one of the columns is data

    type
    > text?
    >
    > Thanks.
    >
    >




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