I want to iterate over all the columns using dbt.
Sorting out similar values in the same column SQL
I’m trying to categorize data that seem to similar from my database table. Here’s how the table looks like id account 1 011 2 11 3 023 4 23 5 456 I need a select query that will categorize my …
PostgreSQL – Does a ‘RETURNING ELSE’ statement exist for an UPDATE?
I have this query: When the update is successful, it returns the following: client_id username isSuccess 1 test_name 1 When the update doesn’t execute, it returns client_id, username, and isSuccess, but their values are blank. What I’m having trouble with is customizing what returns when NO update…
how to insert pandas dataframe into IN operator of SQL
I have pandas dataframe with unique number of user: I want to pass this column to sql query where I use IN operator: I have tried doing this which would retrun whith this ‘1qw3,2wed,3das,4frr,533ew,612w’ and then something like WHERE users in STRING_SPLIT(data_frame, ‘,’) but this one …
ASP classic select date BETWEEN dates on SQL Server
I run the next query in my classic asp code and it run perfect. it returns results between the days “from” and “to” However,I cannot find out what is wrong with the next query: I want it to return the results of the last week that are recorded in the database. Any Ideas? The query is o…
Display all matched records using Oracle Query
I have query in Oracle using Connect by Level to display all matched records with regexp_substr but it doesn’t display all, I need to change the Connect by Level from +1 to +8 to get all the result. …
Postgres Calculating Weighted Average
I am trying to get the weighted average of items from this example table: Item Value Item1 0.10 Item2 0.15 I followed this example here how to calculate it: https://www.wikihow.com/Calculate-Weighted-Average And tried this statement: I am trying to get the average by doing SUM(numberXWeightingFactor) but it d…
SQL – How to print calculated datetime result
If a.modified_datetime is ‘2021/10/01 13:00:00’ and b.modified_datetime is ‘2021/10/01 12:30:00’, the result of this query would be: However, I run this query via sqlplus, it returns What’s wrong with this query, or need to set some options to sqlplus? Answer it is stored in a da…
C# select SQL query with parameter
I would like to migrate database from MS Access to SQL Server and I’m trying to modify my SQL queries. In MS Access they worked. I have this C# code: Connection method : SQL query is working but not returning rows. I guess that problem is a syntax of parameter in query. Can someone direct me? Answer You…
Get percentage of total using sub selection
I have a query that sums sold units and groups them by store. See code and/or SQL-fiddle below: http://www.sqlfiddle.com/#!5/95f29/6 However, I also want the percentage sold by each unit to the total and have therefore created a column named “sold_total”. After the output of this query is generate…