Inquiries about a specific period

AMER SAID 396 Reputation points
2021-06-29T15:02:42.283+00:00

hi
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

110345-untitle2.png

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

110258-medical2.png

Blockquote

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"

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,580 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sam of Simple Samples 5,516 Reputation points
    2021-06-29T15:42:17.007+00:00

    Using the following data (that is different from yours):

    TheName LeaveM DateEnd Id
    Folic 5 MG 2 8/6/2021 1
    Folic 10 MG 3 4/6/2021 2
    Esc 10 MG 4 1/6/2021 3
    Folic 10 MG 5 5/6/2021 4
    Folic 10 MG 2 6/6/2021 5
    Folic 10 MG 1 7/6/2021 6
    Esc 10 MG 1 2/6/2021 7
    Esc 10 MG 3 3/6/2021 8
    Esc 10 MG 4 3/6/2021 9

    The following:

    SELECT DISTINCTROW Medical.TheName, Sum(Medical.LeaveM) AS [Sum Of LeaveM]
    FROM Medical
    GROUP BY Medical.TheName;
    

    Produces:

    TheName Sum Of LeaveM
    Esc 10 MG 12
    Folic 10 MG 11
    Folic 5 MG 2

    0 comments No comments

0 additional answers

Sort by: Most helpful