Ich versuche, das Ergebnis eines COUNT als Spalte in meiner Ansicht zu erhalten. Bitte beachten Sie die unten Abfrage für eine Demo von der Art, was ich will (das ist nur zu Demonstrationszwecken)SQL-Count in Ansicht als Spalte
SELECT
ProductID,
Name,
Description,
Price,
(SELECT COUNT(*) FROM ord WHERE ord.ProductID = prod.ProductID) AS TotalNumberOfOrders
FROM tblProducts prod
LEFT JOIN tblOrders ord ON prod.ProductID = ord.ProductID
offensichtlich nicht das funktioniert ... aber ich frage mich, was die richtige Art und Weise zu tun, das wäre?
Ich bin mit SQL Server