I am new in SQL as well as ASP.NET. For one of my projects I need the following output requried output. So far I have done this my current output. But here some Test Type Name is repeating. How to solve this problem?
My current query:
SELECT
tyi.TestType,
COUNT(tr.TestID) AS NoOfTest,
(Fee*COUNT(tr.TestID)) AS TotalAmount,
FROM
TestTypeInfo AS tyi
LEFT OUTER JOIN TestInfo AS ti ON
tyi.TestTypeId=ti.TestTypeId
LEFT OUTER JOIN TestRequest tr ON
ti.TestId=tr.TestId
WHERE
EntryDate BETWEEN '2016-12-31' AND '2016-12-31' OR
EntryDate IS NULL
GROUP BY
tyi.TestType
Which gives me the output:
TestType | NoOfTest | TotalAmount
---------------------------------------
ECG | 4 | 600
X-Ray | 4 | 800
Blood | 6 | 1800
X-Ray | 4 | 1200
Echo | 4 | 4000
X-Ray | 3 | 3300
Echo | 0 | 0
UltraSonogram | 0 | 0