I would like know how to retrieve all post and verify which one I liked with a dynamic UserId the query that I tried is : SELECT posts.id, posts.content, posts.user_id, users.pseudo, …
SQL query to combine the results from two tables
I have these two tables and I want to build a SQL query: My search criteria is: Name (in field Brother and field Speaker) Congregation (in field Congregation in both tables) I want the resulting view to be a single list of all records, sorted by date (fields Talk Date and Last Given). So: Away Talks I am inte…
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 crea…
Problem using create view and explain plan
I want to test the efficiency of this query using explain plan for. The query works without the explain plan but when I use it I get this errors: I used explain plan on queries without create view and they worked. I don’t know what is causing the error I have tried changing the parenthesis but I get the…
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
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 aggregate values in two different columns under different criteria?
Here’s the table of data I’d like to work on: CUST_REF ACC_NO JOINT_ACC PRODUCT NUM_OF_ACC CALC_FEE ACTUAL_FEE DIFF 100 ABC123 N ACCOUNT 4 140.68 104.14 36.54 100 ABC456 N STOCKS 4 41.72 30.24 11….