I am attempting to search an SQL database for instances where child records do not exist, or if they do exist, they are a specific type (e.g. Historical) and no other types exist (e.g. Current): This populates all of my parent records that do not have any child records without any issues. However, I also want the query to populate
Tag: join
How to mix left and right joins with cross reference table
I’m using Mysql. I have table A(ida) and table B(idb) and a cross reference table CR(ida, idb). I want to capture in a query the relationship between A and B (basically what’s is CR) but I also want all the rows from A and B that have no relations present in CR. To get something like this: I tried this:
Insert rows into same table using data from different rows based on data from another table
I’ve got 2 tables: TimecardSetDetails, TimecardDetails TimecardSetDetails +————–+————-+————–+ | SetDetailsID | EmployeeKey | SetHistoryID | +————–+————-+—–…
COUNT Multiple Columns using GROUP BY – SQL
I am trying to create a GROUP BY COUNT of ~30 columns in my database. The database is basically a shiftplan, where on each column a row can be assigned different shift types (denoted as a D, N, A, X, F, C, etc..). I can use the following query to get a count of each shift type, am struggling to
ORA-01417: a table may be outer joined to at most one other table
I have this query below for oracle sql: When i execute it, i got ORA-01417: a table may be outer joined to at most one other table. Need help for this error. Answer Please use below query. In the current query, your aggregation is incorrect, you have to use same function as you use in the select query. And changed
How to joins in oracle based on condition
I have two tables as below: Table Apple: Table KEEY: Desired Output: Code Tried So far: This is giving me : I guess i need to use pivot instead of Union to get both the ids on same row. Have you ever encountered such scenarios? Any pointers to proceed will be very helpful. Thanks in Advance! DDL used for the
Update column in Oracle table with value from another table with duplicates
I am trying to update the column (REPT_IND) from table A to the value in table B where A.ID = B.ID and some conditions in table B. There are some duplicates in table B, but nonetheless the REPT_IND is …
Depending on column value, query different tables
I have table A where each IDENTIFIER value is unique. Depending on whether its CC or DC, I need to join it with different tables, for example if its “CC_” I need to map it to table B and if its “DC_” I need to map it to table C. TABLE A: TABLE B: TABLE C: I want the result
Count times date occurs between two dates in a second table
I have two tables [Charges] and [Defects] and want to produce [Desired Query Output] where the output counts the occurrances of defect when [Charges].ChargeDate is between (and including) [Defects].OpenDate and [Defects].CloseDate. For [Defects] table, a close date of NULL means it has not closed yet. Seems simple enough, but I haven’t found a good example of how to do this.
Filter country using a JOIN in BigQuery
In a scheduled query in BQ, I am trying to filter countries using an external Google Sheet (already made a table). The query already has a join from two other tables. I would like to enter a SELECT clause in the WHERE statement. I keep getting errors. Any tips as to where I am going wrong? Expected output would be