Skip to content

Tag: sql

Add new column with Boolean in PL/SQL

I’m learning PL/SQL right now and I have a doubt. I have created the following table called tbProducts: And I have inserted some values so the table is like this: Now what I’m looking for is a boolean variable that can be called bUpdate that returns FALSE if today’s date (26-AUG-2021) is gre…

Postgres transpose a row

I have a table which looks like the following :- I want to transpose it to the following form, in Postgres: I know I’m supposed to use the pivot operation to do this, but I can’t figure out the right syntax to get this done. Any help to get this done will be appreciated. Answer That would simply b…

SQL Summing columns based on date key

I have a dataset as given in the link, DataSet I want to segregate the column “order_item_unit_status” as separate column and bring respective transaction amount for the same. Desired output is given below. Objective is to consolidate the txn_amt into respective categories and group them based on …

Grafana change SQL query for a totalization of each data point

I have a grafana dashboard that charts a bunch of data on 2 query’s, this is one below: And this is the other query: Would anyone know how I could modify this into one SQL expression for a totalization? Instead of 50 different lines on my chart, just one line of all variables added together. The data is…

Change + ordered to + leading

I’m trying try to find the most selective criteria to start joining in SQL. I tried this: But this + ordered is deprecated. How I can implement this query using + leading? Answer Use the leading hint and put the table aliases between parentheses in the order you want the database to join them, for examp…