VB6 SQL Group Statment error


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: VB6 SQL Group Statment error

  1. #1
    Join Date
    Jul 2011
    Posts
    2

    VB6 SQL Group Statment error

    Hi All,

    I am working on some software and I need some advice

    I have the following SQL statment

    Code:
        SQLCommand = vbNullString
        SQLCommand = SQLCommand & "SELECT DATECOL, TIMECOL, SUM(ITEMSOLD), SUM(TOTALSOLD) From TimeSales "
        SQLCommand = SQLCommand & "WHERE DATECOL='" & ReportDate_Start & "' "
        SQLCommand = SQLCommand & "GROUP By TIMECOL "
    I am getting the following error when I run the SQL command

    Run-time error '-2147467259 (800004005)':
    [ODBC Firebird Driver][Firebird]Dynamic SQL Error
    SQL error code =-104
    Invalid expression in the select list (not contained in either an
    aggregate funtion or the GROUP BY clause)
    But as you can see I am using the group by clause can someone help me with this as I have spend ALL weekend on this ONE bit of code and it is starting to drive me insane

    Thanks
    Andy

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    When using a GROUP BY, ALL the fields in the SELECT statement not used in an aggregate function, like SUM, must be in the GROUP BY.

    You only have one...your GROUP BY needs to contain both DATECOL and TIMECOL
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. SQL Statment Error
    By Drew_gable in forum VB Classic
    Replies: 4
    Last Post: 03-20-2009, 11:44 AM
  2. Has anyone heard of VCVARS32.BAT?
    By Verrona in forum C++
    Replies: 18
    Last Post: 09-24-2008, 07:43 AM
  3. I can't link FreeImage to C#
    By mesh2005 in forum .NET
    Replies: 1
    Last Post: 03-06-2006, 08:16 AM
  4. Replies: 0
    Last Post: 03-09-2001, 11:58 AM
  5. Winsock32, Connect fails to connect to a peer
    By Chris.G in forum VB Classic
    Replies: 4
    Last Post: 11-13-2000, 03:16 PM

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