I have an sql table looking like this:
+----+-----------+------------+ | Id | EnquiryId | PropertyId | +----+-----------+------------+ | 1 | 1 | 20 | | 2 | 1 | 25 | | 3 | 1 | 26 | | 4 | 2 | 20 | | 5 | 3 | 20 | | 6 | 4 | 20 | +----+-----------+------------+
I want to count how many enquiries propertyid 20 has on it's own, and how many that is shared with other properties
So the result should be something like this:
Number of single enguiry: 3
Number of shared enquiries: 1
It's perfectly fine if it requires two select statements :)
The attempts so far looks like this:
(select count(distinct [EnquiryId])
from [EnquiryProperty] where propertyid=20) as 'SingleEnquiry'
This gave me 4 results (I need it to be 3)
(select count([PropertyId]) FROM [EnquiryProperty] where propertyid=20 GROUP BY propertyid HAVING COUNT(*) > 1) as 'MultipleEnquiry'
And this gave me 0 results