I have 3 tables. Users(id, fullname), Chats(id, name) and Chats_Participants(chatId, userId). I need to select all the chats in which user with specified id consists. For example: Chats: 1. 1, ‘Test’…
How can I apply mutliple filters on my sql tables
I am struggling with what looks to be relational division in sql. I need to filter data from the same table based on multiple criteria. Here-under is a schema of what my table looks like. | ——-|–…
Can we Apply Group By on two columns in Sql Server 2017?
How to get last message of all users who did chat with UserID 1. I want to apply group by on two feilds. The Database is like: MessageID Message MessageCreatorUserID MessageRecieverUserID …
How do I get an overview of which row has a NULL value and whats the name of the column the NULL value is in
I have a table with translations, looking like: table name: text id | en | de | fr 1 | test | NULL | test 2 | thing | thing | NULL 3 | other | NULL | NULL The en column is …
Hierarchical Data In Oracle SQL
I have tbl_parent like this in Oracle SQL, sample data is given below: Id(primary key) parentid childid 1 1 2 2 1 3 3 2 …
datediff for row that meets my condition only once per row
I want to do a datediff between 2 dates on different rows only if the rows have a condition. my table looks like the following, with additional columns (like guid) Id | CreateDateAndTime | …
How to force postgres to return 0 even if there are no rows matching query, using coalesce, group by and join
I’ve been trying hopelessly to get the following SQL statement to return the query results and default to 0 if there are no rows matching the query. This is the intended result: vol | year ——…
Selecting all foreign rows for each row useing a N-N table
I have a N-N table, lets say as an example Teachers and Subjects: There is a Teacher table as follows: There is a Subject table as follows: And there is a TeacherTeachesSubject as follows: Only that each table has more than 10000 entries. I need to make a query which returns me something like this: What I am …
Pivot Table with Dynamic
My quest might be answered in somewhere here but I couldn’t find. So, sorry if I asked in vain. I have a Table that’s populate automatically with precisely date/time in SQL Server and looks like …
Update referencing on subquery (sqlite)
I have a table with md5 sums for files and use the following query to find the files which exist in one hashing-run and not in the other (oldt vs newt): SELECT * FROM md5_sums as oldt WHERE NOT …