Results 1 to 2 of 2

Thread: SQL Query not working?

  1. #1

    Thread Starter
    Join Date
    Jan 2004
    Southern California

    SQL Query not working?

    The below SQL Query isn't returning the results I'm expecting. Obviously it's running correctly based on the code. What I'm trying to return is 1 row of data with the "Total Run(s)" column showing 2. What am I missing? See attached image also.

    SELECT	COUNT(main_ID)	AS 'Total Run(s)'
    		,[load]		AS 'Capacity'
    		,endTime	AS 'Ending Time'
     WHERE  main_ID = 129656
    GROUP BY main_ID, dateCreated, [load], endTime, channel_ID, direction1_ID, angle_ID, direction2_ID

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002

    Re: SQL Query not working?

    it's not what you're missing, it's what you have. The grouping is set to include the Endingtime ... which has a time component. Since both rows have a different time, it comes back as two records. If both records had the same date and time, then it would have aggregated them together. also, your dateCreated has the same issue... the time component is off slightly. If you don't need the time component, then you need to adjust the fields in the select and group by to drop the time component and just return the date.

    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width