I have an audit table that is structured as follows: This table is tracking whether we were able to successfully source a particular data point for a customer. Sometimes we are able to find the data on the first attempt, and you know this because there was no entry with a status of failed, the first occurrenc…
Tag: sql
Remove trailing comma
I have a table with names formatted as “Smith, Stan” and need to display them as “Stan Smith”. I was able to do that but it seems that the comma has been left behind and I need to get rid of it. This is what I currently have: Answer How about using replace as below
How to check if a given database exists on the server?
I am doing a union of same table from different databases to get all the company details. Something like below. This is working fine and I am getting all company details, but I want to make sure that database is exist in the server. Because if any one of the union database is not exist in the server then the
PostgreSQL SQL query to find number of occurrences of substring in string
I’m trying to wrap my head around a problem but I’m hitting a blank. I know SQL quite well, but I’m not sure how to approach this. My problem: Given a string and a table of possible substrings, I need to find the number of occurrences. The search table consists of a single colum: searchtable | pattern TEXT PR…
SQL – sum a column with common id, then coalesce total with another column
I know somebody can tell me what I’m doing incorrectly here. This is a postgresql db. I’m trying to first sum the values in a column that share the same ID, and then add that total (coalesce) with …
I am new to SQL Server. I created a function which action like charindex
I am new to SQL server. I am trying to create a scalar-valued function which will act like charindex. but I am not so sure why when I call the function like it return 0 as result. Thank you so much for your help 🙂 have a great day guys Answer In SQL Server, you need to specify lengths on
Select Query is not working with WHERE clause when there is a space in column value
Select Query is not working with WHERE clause when there is a space in column value. since my table column value has space in it. When I copied same value from query result and put that with where clause, it doesn’t return any result. . if I run below query , it doesn’t return any result SQL Serve…
How to make a start on this SQL query homework? [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question A mov…
All the migrations are working inappropriately
This is the error I get after trying to open the form. Below are the codes. It takes me all day so please kindly help me out. SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘id’ in ‘field list’ (SQL: select max(id) as aggregate from admissions where admissions.deleted_at is nul…
Have I normalized this database to a 3NF level the right way? [closed]
I had a lecture at college recently about normalizing databases, but since we are online I can’t really ask a lot of questions, so here I am. Can someone tell me if I’m doing the conversion right, if …