मुझे एकाधिक तालिकाओं में शामिल होने की आवश्यकता है, एक तालिका में एक कॉलम द्वारा अलग-अलग तालिकाओं और समूह से गणना का चयन करें।एकाधिक तालिकाओं में शामिल हों, एक क्वेरी में एक कॉलम द्वारा विभिन्न तालिकाओं और समूह से गणना का चयन करें
select c.CommunityName, SUM(case when m.ListKey = c.ListKey then 1 else 0 end) as Posts
from Community c with(NOLOCK)
join messages_ m with(NOLOCK)
on c.ListKey = m.ListKey
group by c.CommunityName
select c.CommunityName, SUM(case when b.CommunityKey = c.CommunityKey then 1 else 0 end) as Blogs
from Community c with(NOLOCK)
join Blog b with(NOLOCK)
on c.CommunityKey = b.CommunityKey
group by c.CommunityName
select c.CommunityName, SUM(case when ce.CommunityKey = c.CommunityKey then 1 else 0 end) as Events
from Community c with(NOLOCK)
join CalendarEvent ce with(NOLOCK)
on c.CommunityKey = ce.CommunityKey
where ce.StartDateTime >= GETDATE()
group by c.CommunityName
या बस
select c.CommunityName, COUNT(*)
from Community c with(NOLOCK)
join messages_ m with(NOLOCK)
on c.ListKey = m.ListKey
group by c.CommunityName
select c.CommunityName, COUNT(*)
from Community c with(NOLOCK)
join Blog b with(NOLOCK)
on c.CommunityKey = b.CommunityKey
group by c.CommunityName
select c.CommunityName, COUNT(*)
from Community c with(NOLOCK)
join CalendarEvent ce with(NOLOCK)
on c.CommunityKey = ce.CommunityKey
where ce.StartDateTime >= GETDATE()
group by c.CommunityName
अधिक तालिकाओं नहीं है, कुछ है कि अतिरिक्त आवश्यकता मिलती है ... किसी की मदद कृपया: यह कैसे मैं इस अलग से करना होगा है?
क्या आप उन्हें एक साथ जोड़ नहीं सकते हैं, प्रत्येक समूह को अलग करने के लिए एक स्थिर टेक्स्ट फ़ील्ड जोड़ सकते हैं? – Joe
मैं अभी भी एक बच्चा एसक्यूएल विज़ार्ड हूं;) मैं यूनियन की जांच करूंगा। धन्यवाद! – HLkatie
आपका परिणाम क्या होना चाहिए? विभिन्न प्रश्नों से सभी मायने रखता है? – Lobo