Skip to content

Tag: tsql

Finding Occurrence of the duplicate values

I have table with 3 columns (id, Name, Occurrence), I want to update the Occurrence column ,based on the id column, attached snap for the reference. for example if my id column has “606” value 3 times then my occurrent column should have 3 against all the “606” value. Below is the meth…

How to count rows by date for each of two values?

I have a large dataset in SQL Server that contains two date fields and a foreign key field (among others): I need a query that can count the number of rows for each day, but to count them for each distinct value in the type_id column. The closest I can wrap my brain around right now is returning the total

Joining another tables results to add to a existing query

I want to add RuntimePercentage column to my existing Uptime query for a report. Below is the current queries I use now. To do this I need to join another table results to make it happen but I haven’t been able to find a solution. The where clause gives me a error because UptimeMin is only in table a. H…

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…