I am learning SQL Server, and I have a sample database which I got from my co-worker. I created a stored procedure previously which works fine. Now I am trying to show average of the column which I am struggling at the moment. Your supports means a lot and I will learn from this. So here is my query: And
Tag: sql-server
Sending a HTML based on SQL server table with conditional formatting
I can send a mail based upon a table in SQL. However, when it comes to changing color on a cell based upon a certain value (conditional formatting). I just cant get it to work. I’ve searched on here and can’t find anything based upon a field value. A segment of my code is as follows: When I try th…
Why is DbUpdateConcurrencyException thrown?
I am using an SQL server and I have a table whose purpose is to hold a tree-like structure: The “Path” column value is generated by INSTEAD OF INSERT, UPDATE trigger. I am using EFCore 3.1 and each time I try to add a record into the table, I get DbUpdateConcurrencyException thrown. What am I miss…
inserting a variable into openquery
I’m trying to insert a variable into the openquery expression, but unfortunately I get an error, does anyone know where I got this error? Arithmetic overflow error when converting expression data to int data type. Answer OPENQUERY requires a literal string, you can’t put variables into it. As such…
How to query previous 8 quarters for quarterly data report using sql server?
I want to query the previous 8 quarters from today’s date. Example: last quarter from today’s date = ‘2020-09-30’ and last 8 quarter from today’s date is ‘2018-10-01’. I want the last 8 quarter previous (‘2018-10-01’) mark as Q1 in my query result instead …
Table, Row valued UDFs in SQL Server
SQL Server (and some other databases) support a Table-value function. Is there a such thing as a Row-valued function — where based on a set of input values, a specific row would be returned, or is that type of function type not supported. If not, why isn’t it supported? The example SQL Server give…
Get the Defect Type with the maximum Total Defect Qty
I have the following query which gets the sum of defect quantity per Defect Type : SELECT [Defect Type] ,YEAR([Date]) AS YearOfDefect ,SUM([Total Defect Qty]) AS [Sum] FROM SupplierQuality GROUP BY […
SQL Query count with group by and having at least one date filled
I need to write a sql query where I count number of employees who are not featured. Each employee can have multiple records with member comments. If they are featured then the feature date will have …
How can I create summaries across columns?
I have an existing application database table supporting an application, and I’ve been tasked with adding another feature. Currently, we have a build table that stores information about product builds….
Why ROW_NUMBER is defined as window function?
I would like to understand better the meaning of window function. The definition says: A window function performs a calculation across a set of table rows (the window) that are somehow related to the current row Let’s consider ROW_NUMBER() (the same could be applied for RANK() or DENSE_RANK()). The func…