I have this query: It’s returning: I’m trying to make it like this, if anyone could help me, thanks Answer You can pivot using conditional aggregation: It is unclear what the specific values are that go into each column.
Tag: sql-server
Dynamic SQL :: Calculate percentage of NULLs per index
I have a query that help me list all index in a database and works pretty well: Unfortunately if I uncomment the 6th line the word t.name is underlined in red and if I run the query I receive the error: How can I make this subquery work? The goal is to have a percentage of NULLs on each column
SQL Server Time Format is not equal to Client Side Time format
I’m trying to compare the client side time format (“14:00”) to SQL Server time format (“14:00:00.0000000″) with SQL Query, technically is not equal because SQL Server time format has seconds and milliseconds, so I tried to concatenate the seconds and milliseconds to client side t…
Add ‘iteration number’ column to SQL Select based on same values from two columns
I have a SQL (SQL Server) statement SELECT id, animalId, ownerId FROM myTable ORDER BY id which outputs the following data: id | animalId | ownerId ———————— 1 | 123 | 62 2 | …
How to get JSON string for each distinct field
I have two tables DbContours: _|ContourId | 1|CDCBC42E-2E86-426E-A9BA-00B8B902A153| 2|FDDD2AC5-172D-4A7B-8106-00D05EC1F41C| and SimpleLines: _|SimpleLineId|X1 |Y1 |X2 …
How do I save a result of a calculated select in a column? [closed]
How do I save a result of a calculated select in a column? I want to save(write it) the result of that multiplication in a column of table one like table1.total SELECT table1.quantity * table2.price …
How to select rows from one table, for each row of another table and parse them to JSON
I have two tables DbContours and SimpleLines. One row in DbContours has multiple corresponding rows in SimpleLines via field ContourId in SimpleLines table. I Want to get all rows in SimpleLines …
Microsoft Sync Framework unique index error
I use the MS Sync Framework to sync my SQL Server instance with a local SQL CE file to make it possible working offline with my Windows app. I use GUIDs as keys. On my table I have a unique index on 2 columns: user_id and setting_id: Now I do the following: I create a new record in this table
TSQL – Select Latest Date by 2 Type
I need select data in SQL Server. I have a Data example like this DECLARE @tblA TABLE (ID int, SubId int, Createdate DateTime) INSERT INTO @tblA VALUES (1, 1, ’10/21/2020′) , …
Join fom two source tables into a single column
How would I accomplish this? I’m lost on how to accomplish this. I have a table with relationships to a like named field in two different tables. I’m trying to join them such that the two columns get …