I have a Postgres table with a schema that looks like this – Table “public.nav_due_dates” Column | Type | Collation | Nullable | …
Tag: postgresql
SQL how to find the product group with highest porportion of expensive items
I have a table with products, product_group and price level. How can I find the product group with the highest porportion of expensive items? I have tried this query, but it keeps all price_levels, not just the expensive ones. Essentially, I want to divide the number of expensive items in one product group by the total number of items in
Randomly select orders per customer from database
DB-Fiddle Exptected Result: I have a huge database and need to extract some data from it for a case study. The problem is that I need to extract the full year of the data because I want to be able to conduct a monthly analysis in the case study. Therefore, I can not limit the extract with dates or LIMIT.
Is there a way to parse csv string with escapings via HQL/SQL?
I have a problem parsing csv-formatted data that is stored in a Hive table column that is loaded into PostgreSQL DB afterwards. What I need to do is to retrieve some fields from there, however, if a comma is enquoted, it should be treated as a part of data to retrieve; on top of that, quotes can be escaped themselves.
ERROR: syntax error at or near “.” LINE 4: ON like.takerId = frame.likeId;
i have a table whose name is like. But whenever i have to select data from like, i was getting this error, i figured it out public.like..but when i try to join two tables i get this error i also use public prefix but it throws even if it is saying column like.takerid does not exist , then why it
How to automatically create a comment on CREATE in Postgres?
I would like to create a trigger which gets fired once a table is created in a schema. This trigger should add a comment to the newly created table, something like: With add_comment doing somthibg like: However, it seems I can only add triggers on table level. How could I achieve to add comments to newly created tables in pure
Join date to date range SQL
I have event on the calendar table as follows And I have a table daily as follows I would like to join these table to get the daily with the new column of event name base on specific country, for example: I will consider only US event. So the expected output should be the following table. May I know how
How to translate this jsonb SQL query to an Active Record query?
The following data is present in my Color ActiveRecord model: id colored_things 1 [{“thing” : “cup”, “color”: “red”}, {“thing” : “car”, &…
Calculate exact month-difference between two dates
DB-Fiddle CREATE TABLE inventory ( id SERIAL PRIMARY KEY, inventory_date DATE, product_name VARCHAR(255), product_value VARCHAR(255) ); INSERT INTO inventory (inventory_date, …
Get next row with clause A since last row with clause B
I have the following table: I am looking for a way to get all customers whose status is currently not ‘ok’ with an indication since when the status is not ‘ok’. The result should be: My attempt is the following, but it gives incorrect values for customers that are currently ‘ok’. The thing that I try to figure out is