Skip to content

SQL GROUP BY with LEFT JOIN MS SQL Server

I have a calendar table (c) with a set of 3 month dates: I have a Stats table (s) with views of each product on the website. I need to count the views per product per month whether there are views or not. I have followed many SO answers (SQL – Group By with Left Join) and I cannot see

How to Add missing Months and display TotalPayment = 0

How to Add missing Months and display TotalPayment as 0 I already try row_number but it seems not working Query: Results: brgy month_dt TotalPayment barangay1 January 5345.00 barangay1 February 34232.00 barangay1 March 53454.00 barangay1 April 25234.00 barangay1 May 43224.00 barangay1 June 14.00 barangay1 Jul…

Remove characters after space in sql

I have two tables as shown below: I would like to match these two columns i.e FIRST_NAME from table1 to FIRSTNAME from table2. I tried with the below query but only could match Richard and not Kristin. Please suggest! Answer I would add trim to make sure there’s no whitespace preventing a match.