Skip to content

Tag: sql

Create table which shows earliest and latest date for same names(IDs)

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

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

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 …

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&#…