I pull from a SQL database which sometimes looks like this. A B C D _ E F _ G So when I put it into a data frame and print it as a CSV I want it to look like A, B, C, D, , E, F, , G But instead it looks like A, B, C, D, E,
SQL count rows where column value contains string
I want to count the number of rows where a certain column has a substring in the column value. This doesn’t work Example: I want to count the rows including ‘no’ Expected result: 2 Because ‘no’ is a substring in ‘noa’ and ‘noit’. Answer Use a case expressi…
Problem reading uniqueidentifier from SQL response
I have tried to find the solution for this problem, but keep running my head at the wall with this one. This function is part of a Go SQL wrapper, and the function getJSON is called to extract the informations from the sql response. The problem is, that the id parameter becomes jibberish and does not match th…
MSSQL Check if a SELECT statement will have rows, if yes, then execute the same SELECT statement
I would like to execute a SELECT statement in a stored procedure, but before executing, I have to know if it will have rows. If not, I have to jump to a specified Label, and set an output. My current method works just fine, but I will need more of these in several procedures, and I was wondering if I
Select using WHERE if any exist, else don’t use WHERE
I want to select from a table where column = ‘n’. If the result has 0 rows, I want to remove that conditional. Some pseudo-sql might be: I will only be using the first row in either result, so it would also be acceptable to somehow sort the result such that rows where COL_B = ‘mystring’…
how to divide the amount for each record on specific condition
I have a table let’s assume X and I want to join it to another table Y this the content of X table Y If I made a relationship between X & Y tables the amount it will be duplicated, so if I used sum function the total will be wrong I decided to divide the amount between the stores
PHP/SQL select based on sum result
I’m having a hard time limiting my query results based on sum. Example code: I want to only select states where 0 cities are “covered”. Running my code above the “having” line seems to be ignored (it includes both zero and non-zero cases). I tried using “where” instea…
How to select matching results with other random results in mysql
I want to select all the matching results in a database table with also random results but with the matching results being at the top. With the way, I am doing now I am using two queries first one being the matching query, and if the count is zero I now select random results. I would like to do this
Query using group by with steps/range over large data
I have a table that stores a sensor temperature readings every few seconds Sample data looks like this I want to have the average temperature per device so I ran the following query Where I can pass the time range I want. My issue is that this gives me total average but I want steps or range I want to
SQL Calculate Consecutive hours [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question Need to calculate consecutive hours. Here is the data This the client has a limit of the amo…