Category "sql"

BigQuery query review for session based attribution

I've been struggling for a while to get a query to return the number of sessions and users per source/campaign/medium/content, based on the current session of t

Pivot two columns

I have data that looks likes: stu_id course_name staff_name 1 Economics - 3 Kuzma, Brian 1 History Hulings, Kreg 1 IHS IB Lit of Americ Duncan, Amy 2 Marine Bi

Is there any way to update json column?

ALTER TABLE managers UPDATE JSONExtractString(managers.extra_data, 'name') = JSONExtractString(other_table.extra_data, 'name') WHERE 1 Query above does not wor

In sql I want to a query in which it gives me the duplicates. However, i would like to see the duplicates side by side. Instead of just count

Select employee.id,count(employee. Id), employee.name From employee_database Group by employee.id, employee.name Having count (employee.id) >1

SQL - Generate column from sum of columns from different table

I have two tables: The first one contains numeral values, it looks like this: The id column is the primary key; it has the attribute AUTO_INCREMENT. All col

How query data use offset in kusto (Azure Data Explorer) KQL for paging

How can I realize below SQL query use offset for paging query in KQL. select * from testtable where code = '88580' limit 1000 offset 111 I can't find any funct

Is there any difference between python scripts in airflow and same script in python

I was writing the below code but it is running endless in airflow, but in my system it take 5 min to run gc=pygsheets.authorize(service_account_file='file.json'

How to fix unknown column when working with joins in SQL

The column does exist in the table, however when I run this query, I get an error of "unknown column". I ran explain & describe to double-check my table Er

Right outer join with multiple where conditions

I'm having some issues returning any results from my SQL query. I'm pretty sure it's got something to do with the WHERE condition. I want only certain RULE_ID

group by cols but with a value

Question on the sql, any help is appreciated dataset: a_col b_col 1 null null 1 2 null null 2 expected output a_col b_col gro

NTILE only for values different from zero

I have a column with many zeros and I want to put only non-zero values into N groups of (approximately) equal sizes. All zero values should get group number 0.

Redshift design or configuration issue? - My Redshift datawarehouse seems much slower than my mysql database

I have a Redshift datawarehouse that is pulling data in from multiple sources. One is my from MySQL and the others are some cloud based databases that get pulle

Why the indexes not speeding up the query?

I have the following query: SELECT TOP 1000 * FROM MyTable WHERE Status = 'N' AND Type is not null ORDER BY mytable.id MyTable has 130 million rows. I also

How to group data with SQL

How do I group my Timestream data? The table looks simplified like this: point_delivery_number | measure_name | time | value ----------------

Generate random pairs SQL

Suppose we have these two tables. TABLE1: |column_1 | ... | -------------------- | 'a' | ... | | 'b' | ... | | 'c' | ... | |

SQL Some vertical to horizontal field names/values

What I've read here doesn't quite answer what I'm trying to do. That's why I'm posting a request here and I'm confident to learn what I can do on this subject.

How to use group by function for more columns

I have used following query to get below output from my exisiting database. select date(RaisedTime) as date, object,User,Count(*) as total from table1 where obj

How to extract column names from SQL query using Python

I would like to extract the column names of a resulting table directly from the SQL statement: query = """ select sales.order_id as id, p.product_na

replacing null value

If i am using select coalesce(firstname, surname, petname) as column_name select isnull(firstname, surname) as column_name Where all return the first non-

How do I select floating-point infinity literals from a SQLite database?

I have a SQLite database with a table named measurements, which contains some experimental data measured by a power meter. They're stored as data type REAL in a