I’m trying to calculate the difference between today’s and yesterday’s totals on a column. If a self join isn’t the best way to do that, that is fine, whichever will give me the result I’m after …
Tag: sql-server-2014
Why collation doesn’t work with for xml path in subquery?
I usually use collate SQL_Latin1_General_CP1251_CI_AS to remove accents (diacritics) like this. escrzyaie-escrzyaie Unfortunately, after one of the search queries stopped working, I found out that collation is ignored when used in combination with for xml path in subquery. ěščřžýáíé-ěščřžýáíé It is possible to work around this by using collation for each part separately, but I wonder why it doesn’t work
I want row data of same id in one single row
The Table Format is like I want to result as following Answer first concate two columns and then do string_agg. Here is the demo. output: If you are using older version of SQL Server then try the following
How to calculate the difference in revenue for 2 specific periods from data in a single table?
I am using SQL Server 2014 and I have the following T-SQL query which is supposed to calculate the difference in total revenue based on 2 specific periods. The data to perform the computation come …
Terse syntax to return an empty result set from SQL server
Is there a shorter way to write the following? The “original” question follows. This was was modified may times, explicitly in hopes of stopping Y responses as a result of showing a specific use-case; and [rightly] claimed to be a confusing mess. The use-case is a TSQL query that returns an empty result set in some cases while a ‘real’
Get Values between Each Comma in Seperate Row in SQL Server
I need to insert multiple rows in a database table from a single string. Here is my string it will be comma-seperated values Current string: What I want is that batch 1 should be ignored or removed and remaining part should be added into the SQL Server database as a separate row for after each comma like this Table name
Loop and insert more than one comma separated List in SQL
I wish to loop through two comma-separated values and perform an insert As an example lets consider two variables Using this loop I am able to extract @Answers and can perform insert. But I wish to extract @Qid and insert inside the loop. edit for more clarity it is a feedback module. my result table have Qid and Answer field.
While loop SQL Server
Help me please. I need to write two functions, one that calculates the factorial and another that calculates the sums of euler. To make the euler sums I need to use the function that calculates the factory. I already have the function of factorial but when doing the sums the result I get “NULL” Note: it needs to be done
Combine Data from Different tables in same SQL Database along with the Table Name
I am trying to get data from Multiple Tables in a same SQL Database along with the Table name from which those are taken from. Select [timestamp] ,[User ID] ,[HCA Location Code] …
Join Two Tables Then Transpose Rows From One Table As Column Names
I’m trying to join two tables ColumnNames ID |Name |Type |Status | —————————————————– 1 |Fullname |varchar |Active 2 |Email |varchar |Active …