I have 3 TABLES: movies which has title and id columns stars which has person_id and movie_id columns people which has id and name columns I want to write a SQL query to list the titles of all …
Tag: sql
SQL pivot query to get the result in a single row
I have a users table as I have another user_custom_fields table as and a third custom_fields table Here the problem is I need the result for each user in a single row with all the custom field_name as column header as I have heard about pivot queries but I don’t have much knowledge of SQL. Can anyone he…
Retrieve Specific Text from String where Search String Exists and Not Exists
I’ve got the following code. It returns the correct result for the first two test strings, where it should return the text between the two ****. The 3rd string returns ” abcd two two ****” …
How to select and update row, so that the same row could not be selected again by any user?
I am sending sms to mobile numbers using many apis at the same time, now I want to ensure that only one sms should be sent to one mobile number. I am selecting a row using the following query while selecting the row I want to set field i_sms_sent_count to 1 so that this row could not be selected again
Display a record although the condition return zero record
I have MySql query like this: SELECT name, id_number, hr.id, file, created_at, updated_at From users u LEFT JOIN homework_targets ht on u.class_id = ht.class_id LEFT JOIN homework_replies hr on u.id =…
Best way to create and host a python webapp that takes user input and adds it to sql databases?
I’m currently working on a project to make data entry easier for myself, I have sql tables set up in an azure database, and i can write python code that adds data to them easily enough, but what i …
compute time difference between rows and conditional group by using PostgreSQL
I have data like as shown below: +——-+——-+ | index | time | +——-+——-+ | 1 | 09.00 | | 2 | 09.02 | | 3 | 09.03 | | 4 | 09.05 | | 5 | 09.11 | | 6 | 09.12 | | …
SET parameters to microsoft SQL server to set environment
I have created some microsoft SQL server queries to insert values into some of my tables created. Below are the sql queries i used. Above is a piece of code which i have used for dev environment. Same code with prod instead of dev should be used for production. Is there any way to parameterize dev and prod to…
Get exclusive users in each table
I have 4 tables as shown below For each table I want the count of users that are present exclusively in that table (not present in other tables). The result should look something likes this I have one way of getting desired result as shown below: First Column: Second Column: Third Column: Fourth Column: But I…
PostgreSQL – Get count of items in a table grouped by a datetime column for N intervals
I have a User table, where there are the following fields. | id | created_at | username | I want to filter this table so that I can get the number of users who have been created in a datetime range, …