DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  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.
    >
    >




Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links