So from my table where I have columns: name, date I would like to select names that repeat point out how many times they repeat and then from the rows with same names I want to print out earlies and latest date for that name. After all my table would have columns: name, how many, earliest date, latest date I
Tag: sql
SQL Developer forces capitalization when I create a table
When I create a table with SQL Developer my columns and the name of the table must be capitalized. I want to use lower case but I don’t know how to do it. Answer This is not something that SQL Developer does; it is done by the Oracle database and is the default behaviour. From Oracle’s Database Ob…
Oracle SQL null row order
I have the below table: Name (null) Name1 Name2 Name3 (null) Name4 I would like to generate this output: Name Output (null) Anon1 Name1 Name1 Name2 Name2 Name3 Name3 (null) Anon2 Name4 Name4 With the below query, I’m able to generate the below table Name Output Name1 Name1 Name2 Name2 Name3 Name3 Name4 …
Is there any diff between the results of the following tables?
Basic information:Ollivander’s Inventory from Hacker rank is there any diff between and and why we need to join the original table itself to get the right result? I tried to use Product table from w3schools, it returns the same result except the order of data. Answer Obviously the two queries look diffe…
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”, &…
SQL Get users with max occurrences in table
Given the following table transactions, which records the IDs of sellers and buyers who had a transaction, I would like to determine the user who was involved in the highest number of transactions and …
Add multiplicity as rows
I use Sparx EA to build a relationship database (MS SQL Server). The tool has a function to create charts. I use the query: SELECT system.Name AS Series, systemElement.Name AS GroupName FROM t_object …
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&#…