0

I want a query ms_access in vb.net to search between two different times. Compilation of the drug items in quantities during the period for each group

enter image description here

My attempt does not do what is required. The sum is shown for all the elements together, not each element. enter image description here

  Dim A = Format(DATETIM_START.Value, "yyyy/MM/dd")
            Dim B = Format(DATETIM_END.Value, "yyyy/MM/dd")
            Select    MEDICALPRO_NAME ,(Select SUM(MEDICALPRO_LEAVEM) FROM MEDICALPRO_TB Where MEDICALPRO_CHECK = True    And (((MEDICALPRO_DATEEND) between #" & B & "# And #" & A & "#))  ) As Total_quantities  FROM MEDICALPRO_TB  GROUP BY MEDICALPRO_NAME"


fast2021
  • 115
  • 1
  • 9
  • 4
    Please post the actual code you're running as what you've posted isn't valid VB.net code. Please also don't convert Dates to strings and then insert the strings into a SQL query. Then learn about parametrized queries and use them always. – Slugsie Jun 29 '21 at 15:18
  • 1
    Does this answer your question? [SQL to find the number of distinct values in a column](https://stackoverflow.com/questions/141562/sql-to-find-the-number-of-distinct-values-in-a-column) – Étienne Laneville Jun 29 '21 at 17:41
  • 3
    Looks like a simple aggregate (TOTALS) query to me. Use Access query builder to get the correct SQL structure then transfer that to the code. – June7 Jun 29 '21 at 19:18

0 Answers0