Per writes "Hi SQL-Team'ers - and a happy New Year to you... blurp ;-)I have 2 tables (Company and News)Company-table:CompanyID CompanyName CompanyPhone--------------------------------------1 XYZ Company 555-12342 Test & Co. 555-02223 MyCompany 555-47414 Incorp. Inc. 555-5541
News-table:NewsID CompanyID Subject Body--------------------------------------1 2 bla..bla... bla..bla...2 2 bla..bla... yada..3 2 bla..bla... yada..4 3 bla..bla... yada, yada.5 1 bla..bla... yada, yada.6 1 bla..bla... yada, yada.7 1 bla..bla... yada, yada.8 1 bla..bla... yada, yada.
I want to count the number of News each Company is associated with.And if a Company does not have a News associated the output must write 0 as Number Of news.E.g.:CompanyName Number of News CompanyPhone----------------------------------------------XYZ Company 4 555-1234Test & Co. 3 555-0222MyCompany 1 555-4741Incorp. Inc. 0 555-5541
Could you provide some SQL that solves this task - I'm sure I'm not the only one having this problem?"