Skip to content
Advertisement

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 method which I tried. I tried to find

How to get 1st and 3rd Saturday and all Sunday between 2 dates using sql

Given a date range, I’d like to return all of the Saturdays and Sundays that fall within that range, with these conditions: Include Saturdays only if their ordinal position is either the 1st or 3rd Saturday within the month they fall (not within the entire range). Include all Sundays, along with the ordinal position of that Sunday within the month

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. How

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 July 141.00 barangay1 August 4415.00 barangay1 September 5455.00 barangay1 October 1235.00 barangay1 November 53535.00 barangay1 December 1661.00

Advertisement