Skip to content

Fiscal year from getdate in SQL

I need to get the fiscal year from getdate(). My fiscal year format should be if getdate is today(18/03/2022) then the fiscal year column should show ‘FY22’ I used the below query to get the fiscal year Query Used: enter image description here Answer Add 6 months to the date (getdate in your examp…

linq query to get possible combinations

I have table1 like funid reasonid 1 1 1 2 2 1 2 3 and users table(users will repeat) like below userid reasonid 10 1 10 2 11 1 12 3 13 1 13 3 how to write a query to get the users satisfying table 1 combination {1,2} and {1,3}, so as per the above data userid 10 and

How to unpack array as columns

I have a table that looks like this: date volume_info 2022-01-01 {“temple”: 18348, “benny”: 8524, “polly”: 1698, “sally”: 5860} 2022-01-02 {“temple”: 2000, “benny”: 1000, “polly”: 3904, “sally”: 1776, “benjam…

SQL Server ‘AS’ alias unexpected syntax

I’ve come across following T-SQL today: that yields following result: The part that got me confused was d(c) While trying to understand what’s going on I’ve modified T-SQL into: which yields following result: It was clear that d & m are table reference while letters in brackets c & b…

Count all records and output values once a condition is met [SQL]

I would like to count all customers and return the signup date for the 3rd customer who has signed up. Essentially evaluate the number of customers that signed up and once the count of customers that have signed up reaches 3 to return the signup date and the id of the 3rd customer sample table output table An…

Remove String and Symbols

I am trying to create a query to remove some varchar and symbols from a big string, basically a table will have a column with this format(the information comes from an API call): so the requirement is to take the main “column names” from the sample, so at the end the string will be like: this shou…