Skip to content

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&#…

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 …

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…