SQl, Group by - Error

Discussion in 'C#' started by apollon10, Jan 20, 2008.

  1. #1
    Hi, guys

    I'm trying to execute this sql below:

    strsql="select Name,CName from Task where Name like '%" & request.QueryString("PrintName") & "%' and CName Like '%" & request.QueryString("PrintName") & "%' group by name"

    * Note that i want to group records only by name.

    but it doesn't work and i get this error:

    'You tried to execute a query that does not include the specified expression 'CName' as part of an aggregate function.'

    Please can anyone helpme?

    Regards
     
    apollon10, Jan 20, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    group by cname

    or include name field in query

    or use *

    Regards

    Alex
     
    kmap, Jan 20, 2008 IP