I have a database with three tables: grocery nutrient grocery_nutrient (for many to many) Actually, the database is very big and I am facing the problems by running this query, the SQL browser crashes when I run, if I add LIMIT it works. and this is the query I have written for it. Answer You can simplify you…
Categorizing the columns of one row in SQL
I have a database table with records like the picture: So each record contains columns related to points of the project lifecycle. I need to categorize those columns in order to know how many columns are ‘completed’ or ‘In Progress’ or ‘Not started’ I want the output to be …
select count with another select and inner join
Is it possible to use two “select” in the same query? I tried it but got the syntax error several times. My query example: I would like the result shown to be all queries on the screen. Basically, what I want is that the result shown when executing the query is the first and second “select&#…
MySQL, Determine number of customer doing first transaction on certain store
I have transaction table as below “I want number of newly registred customer who did their first transaction on Store1 during July 01 – July 30” In this case the expected result is 1 which is CustomerID B with OrderID 4 How to query out the data with using EXISTS / NOT EXISTS, but not using …
SQL How to update every nth row which meets requirement
I have a table that I would like to update one column data on every nth row if it meets row requirement. My table has many columns but the key are Object_Id (in case this could be useful for creating …
Subtract from rows with certain values
I have a table created in Materialized view from 10 different tables. Part of it looks like this group_name value1 value2 group1 100 20 group2 200 40 unknown 300 60 TOTAL 600 120 I have to …
SQL – Counting from distinct pairs
I have a table representing sending msgs between friends on FB: Sender Receiver Msgs # Dave John 6 John Dave 1 Sam Dave 2 …
Compound primary key issue with foreign key
I’m getting this error: There are no primary or candidate keys in referenced table ‘User’ that match. I checked for other similar questions but different answers didn’t help me. Are my primary keys …
Postgres – Query that Join two tables
I have two table that need to join them in one table. 1: First Query SELECT cu.user_name, li.successdate FROM logininfo li JOIN user_mapping um ON um.user_key = li.username JOIN cwd_user cu ON …
How to write sql query to get this result
I had two tables as below: request_id update_from_id sw_ref_number raised_by_user_id raised_date 1 0 1 3 2019-08-29 15:08:16.000 id request_id input_id value is_deleted 21 1 1 00001 0 22 1 2 3 0 75 2 1 00002 0 76 2 2 0 My query is: And after that my result is: request_id sw_ref_number value input_id 1 1 00001…