I have query that should update columns only if argument is equal 1. Here is example: I would like to move this SQL query to stored procedure. How I can achive the same process with SQL code only? Instead of <cfif form.status eq 1> title = @title,</cfif> how that can be replaced with SQL code? I u…
Error while connecting to SQL Server. The server was not found or was not accessible
I am trying to connect to my SQL Server database. I am using C#. Here is my code: string connectionString = @”Server = tcp:, 1433; Initial catalog = ; …
SQL how to do a LIKE search on each value of a declared variable
I have a query where I am trying to do a LIKE search on each value of a declared variable, instead of doing a like search on the entire field value/string. Example: The record I am looking for is “John and Jane Smith”. The query above returns NO result. If the user searches just ‘John’…
How to use expression as LAG() second parameter on MySQL 8 (like MSSQL)?
I am trying to migrate this SQL SERVER query: dbfiddle link To MySQL 8 (same query): dbfiddle link Unfortunately I got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘*(SELECT MIN(sales) FROM product_sales…
Split String and Count Teradata SQL
I would like to split column ‘ASPCT_VLU_NM’ and count of occurrences of the timestamps in a given time frame. For example return the ID which have more than 3 occurrence in between 1537160520286 and 1537190520286. In the example below those are the timestamps : Answer If you are using Teradata 14 …
How to search the string in query with case insensitive on Clickhouse database?
I am developing site using PHP and backend ClickHouse database. When i using like queries , it is not supporting case-sensitive words. select id,comments from discussion where comments LIKE “%Data …
Compare two tables for a matching value from the respective columns and identify records missing
I have two tables and data like below: I want to compare two table’s columns “Type and MatchType” and identify the Ids of first table where Type is missing in MatchType. “Type” and “MatchType” are …
Find the manager details where all the employees under the manager should have salary more than 1000
Im having the table with records like below and i need to get the manager details where the all the employees under the manager should have salary more than 1000 Answer Here is a solution that uses a correlated subquery: This ensures that: the selected employee is a manager (ie they manage at least one employ…
What is the difference between count (*) and count(attribute_name)?
Is there any difference between COUNT(*) and COUNT(attribute_name)? I used count(attribute_name) as I thought that it would be specific hence the searching process would be easier. Is that true? It would be great to see any example with sql code with my issue to help me understand better Answer Imagine this t…
Get the last dates from multiple columns
This feels like it should be an easy one. How do I get the latest dates that are in different columns DROP TABLE #indebtedness CREATE TABLE #indebtedness (call_case CHAR(10), date1 DATETIME, date2 …