Skip to content
Advertisement

Tag: mysql

Not getting proper data while join two query in Mysql

Hi Everyone i am writing a query one query getting weekly data one is getting yesterday record from same table, when i execute both query separatally its working properly but when join both query then yesterday data query not getting proper output. Sampal data https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=8a678d12df7643000838c2f442d4d85a query 1- weekly data quary-2 yesterday data expected output, driver_id car_number day1_trip day2_trip day3_trip day4_trip

SQL query returning 0 rows after adding extra INNER JOIN

The issue is simple to explain, but seemingly not so simple to solve. This SQL query returns 0 rows: This one, however, returns 1 row as I expected: The only difference is the lack of INNER JOIN with the org_depts table. What I want to be returned is all the column values from app_handover, which references sys_logins.id in its sent_by

SQL query for duplicate rows based on 2 columns

I have 3 tables movie, rating and reviewer movie has 4 columns movieID, title, year, director rating has 4 columns reviewerID, movieID, stars, ratingDate reviewer has 2 columns reviewerID, name How do I query reviewer who rated the same movie more than 1 time and gave it higher rating on the second review. This is my attempt at query to

Query table with composite primary key, excluding specific rows

I would like to know which unique ids belong to category A but NOT category B. In the example above, only id: 2 would be a valid result I came up with this which does not work as intended: A valid approach would be to use a subquery Is it possible to do this with a single query? Answer Use

Convert SQL commands to Python

I have the following code in SQL: I’ve been trying to rewrite it in python like so: but I keep getting a generic error message. What am I doing wrong? EDIT: added the error message Answer IIUC, you could try the following: The equivalent of SELECT DISTINCT col is drop_duplicates(col) and the equivalent of SELECT col, count(*) is value_counts(col).

How to avoid showing duplicate rows because conditions

The problem is where name_1 writes something to name_2 and name_2 writes something to name_1 there is a duplicate and as one result because I SELECT name_1, name_2 with condition How is it possible to show results with no duplicate rows, I only want to know if there is communication between user_1 and user_2 Answer Order the names in a

Suggested way to resolve column name/type in a view

I have the following problem that I’m trying to find the best solution for. Let’s say I have a view such as the following: What would be the fastest way to resolve the field names and types of the view? For example, on the above I am looking to get something along the lines of: The first approach is just

Advertisement