Calculate duration using TSQL
I have a table containing columns (Date , PumpStatus)
Table1:
Find occurrence of transport status
I have 2 Tables “Transport_Status” and “Receipts” where the id number is the key and can occur in Transport_Status more than once.
T-SQL Pivot with Square Brackets
I have a table of key-value pairs that I want to pivot.
T-SQL Pivot with Square Brackets
I have a table of key-value pairs that I want to pivot.
SQL server behaviour when both incrementing a variable AND updating a column
I’m attempting to replicate the issue described in this previous S.O. question, where the goal is to:
Invoking a Stored Procedure with all Combinations of Values Stored in Multiple Single-Column Tables
Below, I show the tables I am working with and present the problem I am trying to solve.
Insert leading spaces, then the value to a field in varchar(10)
I’m using the database (SQL Server) of an old program, and want to make batch inserts on the SUPPLIERS table which key is varchar(10). The thing is that the old program fills the key with leading blankspaces to complete the 10 characters, example (underscore represents blankspace)
=’_______310′, ‘_______311’…, ‘______1000’.
how to insert leading spaces, then the value to a field in SQL SERVER varchar(10)
I’m using the database (sql server) of an old program, and want to make batch inserts on the SUPPLIERS table which key is varchar(10). The thing is that the old program fills the key with leading blankspaces to complete the 10 characters, example (underscore represents blankspace)
=’_______310′, ‘_______311’…, ‘______1000’.
How to select the next lowest value and next highest value from a specific record value that’s been flagged?
EmployeeID EffectiveDate EndDate Salary ContractFlag 100 01/01/2022 12/31/2022 10,000 Completed 100 01/01/2023 12/31/2023 20,000 Completed 100 01/01/2024 12/31/2024 30,000 Active 100 01/01/2025 12/31/2025 40,000 Pending 200 01/01/2022 12/31/2022 25,000 Completed 200 01/01/2023 12/31/2023 35,000 Completed 200 01/01/2024 12/31/2024 35,000 Active 200 01/01/2025 12/31/2025 40,000 Pending 300 01/01/2022 12/31/2022 10,000 Completed 300 01/01/2023 12/31/2023 20,000 Completed […]
HAVING Count clauses with conditions?
Say I have a table with orders on it. Those orders have an OrderType
column indicating what kind of order it was.