The title may be confusing so I need to clarify. I have the following survey dataset that I need to transfer to a PostgreSQL database. Where -10000, -20000, and -30000 all represent a null value, but due to different reasons. (e.g., -10000 means that the participant was not shown the question about the column…
Tag: sql
How do I create a structure for a dynamic SQL query?
In my Golang application I make SQL request to the database. Usually, in the SQL query, I specify the columns that I want to get from the table and create a structure based on it. You can see an example of the working code below. QUESTION: What should I do if I don’t know the number and name of columns
Binding dates to SQL in Python for cx_Oracle
I am using the following query to select logs fro a logs table. I have the following dictionary of parameters: and executing the query as follows : Now the problem is I am not getting any values for this date range. But if I execute the query in Oracle, by specifying the dates, it is working. What is wrong he…
Update the Unique number for the co-related records between two columns in the group
I need to identify and update co-related records associated rank under Req_Result column as depicted below. Table name is tblSource. +——+—–+—————–+———+ | Item | key | …
Scan row into slice
I want to Scan a sql.Row into a slice like so: but I am getting this error: 2020/02/23 20:05:14 raw query: SELECT * FROM user_table LIMIT 500 2020/02/23 20:05:14 sql: expected 6 destination arguments in Scan, not 0 anyone know how to make this generic without using a slice? Answer You can do it this way: on t…
How do I get only the person with the top TotalsS for only one team?
I am using SQL Server. I created two views to get a few results and then made them into one select to use on the inner join. I’m sure there’s an easier way to do this. I couldn’t think of anything else at the moment. Please teach me! My results What I’m looking for Thank you for your t…
How distinct works in sql?
I tried to understand how the distinct (and therefore distinct count) work. I have a data with: While within 1 SessionID there is 1 User_solici. However, there could be multiple SessionID for the same User_solici. For User_solici of “a”, I have Session = 1, 55 and null. I want to find distinct Ses…
Multiple joins on same table
I’m trying to achieve a query which seems simple but I can’t make it work correctly. Here’s my database tables structures: Here’s what i want to achieve: Mutliple members can register to an activity. Then, i group the registrations by tandems. I want a view with all the tandems listed …
How to identify best Max_bucket and Seed_value for Oracle ORA_Hash function?
I am new to Oracle Hash function. I know that this function is for encryption purpose. It is actually convert a very large paragraph into one single hash value. The Ora_hash function have three different parameters: Expression Max_bucket Seed_value For the Max_bucket and seed value, the document says I can sp…
PostgreSQL: exclude complete jsonb array if one element fails the WHERE clause
Assume a table json_table with columns id (int), data (jsonb). A sample jsonb value would be When I use an SQL statement like the following: … the two array elements are unnested and the one that qualifies the WHERE clause is still returned. This makes sense since each array element is considered indivi…