Complex Access query - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Complex Access query

isqureshi66isqureshi66 Posts: 3Member
We receive a lot of products and perform some tests on these products. We generate report about lot of products. Report has two parts master and detail. Detail contains serial_no of products, quantity and result. Products can have results that are in table RESULTS_MT.
Requirement:
We need to count the TEST_REPORT_NO from table TEST_REPORTS_MT group by TEST_REPORT_DET.Result
There are 10 reports in total in TEST_REPORTS_MT table and count of them is as follows.
Qualified Fail R&D In Process Qualified & Fail Mix
3 2 2 1 2

The query should be simple and do not contain UNION as the query will be imported in data environment of VB6 as a view and will be used as data source of report.
My query named ResultSet1 outputs 17 reports whereas total 10 reports are present because it counts some record again. That

Comments

  • dokken2dokken2 Posts: 532Member
    your query is returning the count of test results, not test reports.


    try one like this which counts the results and groupby on report-

    SELECT ResultsView.Report_ID, Count(IIf([Result]='qualified',1,0)) AS Qual, Count(IIf([Result]='failed',1,0)) AS Fail, Count(IIf([Result]='in process',1,0)) AS InPr, Count(IIf([Result]='rnd',0)) AS RnD
    FROM ResultsView
    GROUP BY ResultsView.Report_ID;
  • dokken2dokken2 Posts: 532Member
    your query is returning the count of test results, not test reports.


    try one like this which counts the results and groupby on report-

    SELECT ResultsView.Report_ID, Count(IIf([Result]='qualified',1,0)) AS Qual, Count(IIf([Result]='failed',1,0)) AS Fail, Count(IIf([Result]='in process',1,0)) AS InPr, Count(IIf([Result]='rnd',0)) AS RnD
    FROM ResultsView
    GROUP BY ResultsView.Report_ID;
  • dokken2dokken2 Posts: 532Member
    your query is returning the count of test results, not test reports.


    try one like this which counts the results and groupby on report-

    SELECT ResultsView.Report_ID, Count(IIf([Result]='qualified',1,0)) AS Qual, Count(IIf([Result]='failed',1,0)) AS Fail, Count(IIf([Result]='in process',1,0)) AS InPr, Count(IIf([Result]='rnd',0)) AS RnD
    FROM ResultsView
    GROUP BY ResultsView.Report_ID;
Sign In or Register to comment.