Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would start with a plain SELECT query to figure out the WHERE clause. Once you get that working correctly, convert it to a GROUP BY query. </p> <p>So see if this one targets the correct records:</p> <pre><code>PARAMETERS [Start Date] DateTime, [End Date] DateTime; SELECT t.field1, t.field2, t.field3, t.column_date FROM table1 AS t WHERE t.field1 Like '*xyz' AND ( (t.column_date Between [Start Date] And [End Date]) OR ([Start Date] Is Null And t.column_date = [End Date]) OR (t.column_date = [Start Date] And [End Date] Is Null) OR ([Start Date] Is Null And [End Date] Is Null) ); </code></pre> <p>Assuming that first query returns the correct rows, I think this GROUP BY query may give you what you want.</p> <pre><code>PARAMETERS [Start Date] DateTime, [End Date] DateTime; SELECT t.column_date, t.field1, t.field2, sum(t.field3) FROM table1 AS t WHERE t.field1 Like '*xyz' AND ( (t.column_date Between [Start Date] And [End Date]) OR ([Start Date] Is Null And t.column_date = [End Date]) OR (t.column_date = [Start Date] And [End Date] Is Null) OR ([Start Date] Is Null And [End Date] Is Null) ) GROUP BY t.column_date, t.field1, t.field2; </code></pre> <p>If running this query from classic ASP, you will need to substitute the ANSI wild card character <code>%</code> for the Access-style <code>*</code> wild card.</p> <pre><code>t.field1 Like '%xyz' </code></pre> <p>Or consider using <code>ALike</code> and the ANSI wild card instead of <code>Like</code>. That way the query will always operate the same without needing to switch wild cards.</p> <pre><code>t.field1 ALike '%xyz' </code></pre> <p>Also, with classic ASP, run the query from an ADO Command object, and supply values for the parameters.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload