This could be the first of many questions I raise around Azure as I am currently on a mission to tidy up our Azure platform that has previously been setup by other teams. Our SQL Servers that have been setup on Azure have had no tags setup and I want to setup some new tags now on all our existing
Tag: sql-server
how can i check if value exists before the date specified in sql server
I have the data below in a sql table, let assume the user wants to get data of 2020-11-13 which is but i’d like to get the previous supplier due as well before the date specified which is along with so the actual query i wanna get is this and if there is no previous due i wanna return i
SQL Server find rows approaching a service day and month
I have a table which lists equipment with an installation date. These items need to be serviced annually or every five years. So the rows have a service interval of 1 or 5. Something like: What I need to do is return a list of equipment two months before they are due for service For simplicity Let’s ass…
Select max value for each company in list, display longest value per company per day
I’ve looked at some of the other questions similar to this, but nothing I’ve found can quite get me there. I have a table with multiple columns, but 3 of the columns are Company, Date, and WaitTime. I want to select the longest WaitTime for each company and for each day. I’d like to display …
SQL Server : calculate column value based on value in previous row/id
I have what I hope is a simple problem to solve, but one that is puzzling me. My table can be created with the below sql: Which looks like this: This is basically a currency conversion task (the costs in the es-mx row are arbitrary in this example). What I wish to do is update all the TotalProjectCost values …
Joining back on the same table in SQL server
I have a table like below And the output I require is The match is defined on the basis of PO number. If PO number exists in both the sources then it should be match else only in AAP and only in SNW respectively. Can this be achieved? Thanks, Ani Answer or
Error – Select statements included within a function cannot return data to a client
I am trying to create a function that will query times in a table and then return the correct time based on the site. The times in the table being queried have the opening and closing times of the branch. I am not sure if I should be using CASE or IF. When I use CASE, I get this error:
Finding whether duplicates exists in 2 select statements
Could you please help me with SQL statement to find duplicate names present in first Select statement and the second. For example : I need to find whether student with same name in Class 1 is present or not in Class 2 or 3. and Second select statement is : If there is matching occurrences for any name then I
SQL Server select query based on logic
I have the below table : ID Package 1 T 1 E 1 B 1 F 2 E 3 E 3 F 4 F 5 B 5 F I need the below output table : ID Package 1 T 2 E 3 E 4 F 5 B Priority list for the …
How can I calculate a percentage from values obtained by 2 different queries in SSMS?
First query: select COUNT(EUpdate) from EmpUpdates where EProj = ‘abc’ and EID = ‘101’; Second query: select COUNT(EProj) from EmpUpdates where EID = ‘101’; percentage = (first query / second …