Skip to content
Advertisement

I want to update a string in a table

I have a table, content_history with a column, doc_filename, and each row has a string value. Each string has a | and the portion in front of the | is a filepath. I want to replace that portion of the string with the correct filepath if it doesn’t already match. What is the best way to go about doing this?

How to aggregate upvote and post tables together in postgres?

I’m looking for a way to aggregate posts and the upvotes related to that post together using PostgreSQL. I want to make it similar to reddit’s upvote systems, where upvotes come already fetched and don’t need to be loaded on client side. I have made these simple tables. upvotes.sql users.sql posts.sql Basically I want to make my response look something

How to show pivot data without directly using pivot statement?

I am trying to pivoting the data without directly using the pivot function. I have a simple table t1 which has: My expected output is: I want to achieve this without using pivot. I tried using: How can I achieve the output without pivot? Answer You are sort of there, try the following: See Example Fiddle

How to list 3 largest numbers from table in SQL?

I’m trying to unite two bits of SQL codes and list three largest numbers from it. Here is table relation diagram Query #1: Query #2: My final code shows the full list of all first and second names, simply adding largest number to all of them from orders table. How can I modify it to make it show three names

How can multiple unique in partition tabale?

I have a SQL table like below. I have a table. I need to unique order_no column with user_id column. there is no any problem. But I have to unique data_time column because of I use partition. but date_time column has to be separated with user_id and order_no. By the way I don’t want like this unique (user_id, order_no, data_time)

Calculate the time period a certain field is overlapping in SQL Server

I am currently trying to figure out the overlapping time period between records. I already have a query that indicates if it is overlapping another field with ‘yes’ and ‘no’. But I need to have the exact duration of the overlapping time period when the field has ‘yes’ as indication. Can someone help me with it? Query: Result: Answer Check

MySQL- Find records with overlapping period

I have a table hotel_booking reference start_date numberOfDays ABC 11-08-2021 2 DEF 12-08-2021 2 GHI 13-08-2021 3 JKL 10-08-2021 2 So the first task I wanted was to get all bookings which has startDate between x and y date which is straight forward query This returns me ABC and DEF which is perfect. Now I want to check for all

Return type of table function with joined result-set

As a follow-up to Parametrized CTE, What would be the following return type for creating the following table function in postgres which returns a result-set containing two joined tables? For example, converted to a function it might be something along the lines of: Answer You have two options. You can create a custom type containing all the resulting columns. Then

Advertisement