I have a table that stores patient lab test results. There can be results from multiple tests like Albumin, Potassium, Phosphorus etc. First reading for each patient from each of these categories is …
Tag: sql-server
Join on TOP 1 from subquery while referencing outer tables
I am starting with this query, which works fine: SELECT C.ContactSys , … a bunch of other rows… FROM Users U INNER JOIN Contacts C ON U.ContactSys = C.ContactSys LEFT JOIN …
T-SQL Union (distinct, not all) and Order by with priority
Assume I have a Tag table (Id int and Name nvarchar(100)) with 3 values: 1 Software 2 Hardware 3 Warehouse Now I want to query with keyword, and prioritize the ones that starts with the keyword over …
Left join not returning null records
I’am dealing with a pretty basic SQL query, but I cannot understand why the non matching records are not represented with the null values in right table. I have table A and table B with a composite …
Using inner join instead of subquery
I wrote a query using a subquery, but I wonder if there is any way to write it using only inner join (or other joins) since it’s more efficient. /*2. List the name of the sales rep who serves the …
Port MySQL script to MS SQL -> simultaneous data asignement and retrieval
I have been trying to make this work for hours but I can’t really find a way to do it. I have a MySQL script that I need to migrate to MS SQL 2014, however, I can’t seem to make it work. As far as I …
SQL Pivot String Data
I have a tables in SQL Server: Product Product Table: This is the output that I need: An ImageID can have maximum 3 ProductID It is not necessary that all ImageID will have 3 products [eg. ImageID=3] Answer Your were very close, you just needed to incorporate Row_Number() Example
Spark SQL Partition By, Window, Order By, Count
Say I have a dataframe containing magazine subscription information: subscription_id user_id created_at expiration_date 12384 1 2018-08-10 2018-12-10 …
SQL Server : delete user
I’m trying to write a query to delete a user registration from my SQL Server database, but when I try to delete a user, I get this error: System.InvalidOperationException: ‘ExecuteReader: …
Get FileStream size (sql server) by mvc app context asp net mvc
I would like if .net (asp.net mvc) provides possibility to get size of FileStream having DbContext. As I did research so far I can: 1) SELECT SUM(DATALENGTH(‘ColumnName’))FROM Table 2) SELECT …