Skip to content

Tag: sql

sql: long to wide format without using PIVOT

I have a table like the following: I want to convert the data to wide format like the following: the SQL I used does not have a pivot choice so I am wondering how to convert the long format to wide without using PIVOT. Answer If I understand your question correctly, you can do conditional aggregation: Maybe y…

Variables in SQLITE Python

I am working in Jupyter Notebooks using pandasql, which uses SQLight syntax. I am trying to select entries from a certain month, depending on a variable. I am planning to create a Python function that will change the value of the variable being used, but right now I am trying to get “Parameterized Queri…

How to write this kind of query in Oracle

I have a MySQL database and I want to migrate all query to Oracle and since I am not an expert in Oracle SQL I am stuck here. I have query like this My question is: How to write this ORDER BY expression in Oracle SQL? Answer You can use There is no column naming format containing back ticks in

Can’t return column table when the table have just FK?

When I choose a table when it doesn’t have any Primary Key, my query returns nothing. So what’s the problem in this query? This is result when I have pkin my table: And this is result when I haven’t pkin my table: Here is the query: Answer As you are putting INNER JOIN with PRIMARY KEY const…