how to show empty value for a int datatype in SQL? I have a case statement on an int datatype column to show empty for the values less than or equal to 0. case when [TotalValue]
Tag: sql-server
SQL LIKE operator with aaa% having strange behavior
In my case I have patient table with few columns including patient’s firstname and lastname. Application using this table having patient search functionality with firstname and lastname. Having some …
Getting Distinct Id(FK) by the latest date in SQL Server
I’m currently working on a query where I need to distinct ID based on the latest date created. Here is my diagram | ID | ModelID | LocationId | DateCreated | |——+—————-…
Extract a specific value from a string in a column
Need help with a situation, I need to extract a specific value from a column containing string. The string varies over different records, but the value I need to extract is always preceded by the word “VERSION” I tried to user REVERSE & SUBSTRING but not able to get exact results. Any help wil…
Adding missing records from another columns in a different table
I have 2 tables : Table A: A | B | C | D qwe 4 2019 10 qwe 2 2020 5 qwe 5 2019 5 Table B : A | B 3 2019 4 2019 5 2019 6 2019 7 2019 8 2019 9 2019 10 2019 11 …
How to do sub-string calculations in SQL?
I am working with a table full of customer online orders. Each order has a company code which can be either ’09’, ’07’, ’04’, ’03’, and ’01’. Each order has an order number that looks something like …
Average across rows in SQL Server 2008
I have the following table Data Data1 Data2 YTD ————————- 1 2 3 2 3 4 3 3 6 In the YTD column I have to average the rows data. I can …
Return opposite transaction value rows
I have this table structure and I want a query that needs to be returning opposite side columns values. If I pass parameter with value Overtime then it should return following rows The logic is against each transaction if the selected Account is on Debit side it should print the Credit side accounts and if th…
How to get hours between two dates in SQL Server?
I have two dates 2019-01-02 12:33:36.000 and 2019-01-09 19:05:18.000 I want to calculate the hours and mins between the two excluding Saturday and Sunday. I can calculate the difference but not sure …
SQL Query for getting the output as shown in the example shared
For this sample data: create table test (T1 varchar(20), M1 varchar(20)) insert into test (T1, M1) values(‘1930188’, ‘184962’) insert into test (T1, M1) values(‘1930188’, ‘185007’) insert into test (…