I have a data frame like the picture below. In the case of “null” among the values of the “item_param” column, I want to replace the string’test’. How can I do it? df = sv_df….
sql dw count(*) with selected columns doesn’t aggregate
This is rather strange, and I have had this query work on numerous databases but here I am stumped. I know that my Synapse table has duplicates SELECT nmiandnmisuffixkey, ReadingDate, IntervalNumber …
Why SUM values are wrong in postgresql query?
I use postgresql and I have trouble in forming the correct query to get the desired result. I have a query And it gives me result as below. I wish to get the result like So I tried to SUM the third column and so changed the query a bit like this, But the result is like below, Fist this
How to add a ranking to a pyspark dataframe
I have a pyspark dataframe with 2 columns – id and count. I want to add a ranking to this by reverse count. So the highest count has rank 1, second highest rank 2, etc. testDF = spark.createDataFrame([(DJS232,437232)], [“id”, “count”]) I first tried using and this worked, ish. It…
Sum up all values from a list PLSQL
I want to sum up all values from a INDEX BY TABLE list. In the list there are values like this: 24000, 4500, 7890 and so on. This is the code: Answer Lets assume that you have an associated array and you want to sum up the values within it. And, lets also assume that the associative array’s index is
SQL: Select Rows which does not have a corresponding userID in second table
I have 2 tables below : Messages On this table, for a particular Message, if it has a type ‘Q’ it’s a question. Else it’s a conversation from 2 users. Conversation Table This keeps a track of conversations and has questionuserid and answer userid Now from the table above, I would like …
MySQL select based on earlier row’s data (audit table)
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…
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…