I am getting the following data: and I want to get the data before the -. For 42ND-1000 I want 42ND only. Answer This is basic string manipulation. In SQL Server, you would do:
Tag: sql-server
Where clause only return one condition instead two using OR
I have a simple select statement like: SELECT * FROM [customer] AS [c] INNER JOIN [customertype] AS [ct] ON [c].[CustTypeKey] = [ct].[CustTypeKey] INNER JOIN [ProjectCustomer] AS [pc] ON [c].[…
Complicated logic of group by and partition
I have the table as per the script below. The data that I want finally is shown in the screenshot. The logic that is to be implemented is : If SUM(FPR_QTY) > QPA, Use QPA without summing it up. Else, …
Meeting 2 conditions in 2 different columns
I’m trying to run a query where I need very specific conditions to be met: Sales code is All Item has Original Price flag set Item has a price with no Original Price flag set that is the same as the …
Updating bool to non-nullable in sql server
I’m looking for the equivalent of the query below for bit data types Sql(“ALTER TABLE Table_name ALTER COLUMN column INTEGER NOT NULL”); Thanks
How to Pick Column names from table
I have tables which have columns and tables Name EmpId Empname DeptID DeptName Employee Department I have INFORMATION_SCHEMA.COLUMNS to get Table names Script : I have got table names Select …
SQL – trigger select into after update/insert
i have a table called Audit_Data, and from time to time there is an update coming. Every single update consists of around 300 rows (around 20 columns per row), and all of the rows from the same update …
Coalesce(null,”) gets null in Oracle and gets ” in SQL Server?
Oracle version : 12.1.0.2.0 SQL Server version : 2012 My code: in Oracle returns null result, but in SQL Server returns a ” result. Why did this result differ? They are ANSI standards, shouldn’t it be the same? Answer In Oracle document about NULL Oracle Database treats a character value with a le…
Sort Records comparing sums across multiple tables
In SQL Server, I am wanting to bring back all jobs where To make it easy to see what results I should get I added the following table and updated the inserts into tables. InvoicedRecieved is ignored for simplicity. Jobs 2,4 Should be returned. I also need another statement bring back the number of jobs per us…
Combine queries to show one set of results
I have two separate queries where I need to match up and combine together based on a date value. select convert(varchar,Delivery_Date,101) as ‘Date’, sum(case when billing_group = ‘3’ and …