Is this possible to calculate this?

Is this possible to store the decimal type value in number column. 1/12 will be 0.083 and wants to store that in that column. create table test(number1 int,number2 int,number float) insert into test …

Select by code and if there is no result select any other

Imagine there are some table with some data: id | code | name —————- 1 | 0001 | qwer 2 | 0002 | rtyu 3 | 0003 | asdf There can be only one record with code == 0002. Also it may be absent….

T-SQL Trigger – Audit Column Change

Given a simple table, with an ID what is the correct way to audit a column being changed. I am asking after looking after various answers which seem not to be working. Here is what I have: Create …

How to split an array of objects in SQL?

I have a table in my database which has the following columns: ID Data 1 [{“na”:false,”answer”:1.5},{“na”:false,”answer”:0.5}] 2 [{“na&…

How do I make an incremental ranking per query system on SQL Server 2019?

Currently on SQL Server 2019, I have the following code: SELECT dbo.GroundTruth.QueryId, dbo.GroundTruth.Q0, dbo.GroundTruth.Id, RANK() OVER(ORDER BY dbo.GroundTruth.Similarity DESC) …

SQL Subquery within a subquery [closed]

I am writing a nested SQL where I need to have a subquery within a subquery Let’s say I am trying to retrieve a row from ORDERS that matches MAIN_ID from SOURCE that matches MODULE from MODULES. …

Calculate cumulative product value

I have the following database table: Date Return Index 01-01-2020 0.1 Null 01-02-2020 0.2 Null 01-03-2020 0.3 Null I would like to update the Index value using the following …

Apply multiple count conditionally in SQL Server query

I have a task table which contains some DateTime type columns like completed, pending, exception. It joins user table and I want to bring userName, AllTaskCount, AllPendingTaskCount, …

Calculate cumulative value in update query using SQL

I have the following database table: Date Return Index 01-01-2020 0.1 Null 01-02-2020 0.2 Null 01-03-2020 0.3 Null I would like to update the Index value using the following …

Getting the latest status of user before every calendar Date in SQL

I have 2 tables as below: Table 1: UserID DateEntered Status 1 29/03/2021 a 1 30/03/2021 b 1 31/03/2021 a 2 01/04/2021 a 3 02/04/2021 c 2 03/04/2021 c 3 04/04/2021 a 4 05/04/…