I have tables as Cust1 +—-+——+————-+ | ID | Name | Referred_id | +—-+——+————-+ | 1 | aaa | | | 2 | bbb | 1 | | 3 | ccc | 2 | | 4 | …
How to join tables on calculation – Oracle [closed]
i am trying to join these two tables, but I can only do so if I change values of columns while joining like “substr(to_char(p.personnummer),3)” and “substr(k.ip_id,1,10)” . Can anyone tell me what is …
how do I pass a date in text format to DATE format with sql [closed]
I have a table called sale where I have a field that saves the date DD / MM / YYYY the type of this field is text now that I need to make filters with that date I have had problems with consulting the …
How can I resolve “success with compilation error” error while creating trigger in Oracle PL/SQL?
I am trying to create a trigger that updates “event” table rather than updating the “v_event” view. When I run this script I get “success with compilation error” error. What am I doing wrong? Answer Pay attention to what you do. In order to find out what went wrong, either …
How self join works [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question I hav…
Left join matching between dates
I am trying to pair the date of a national holiday with time bucket boundaries. I would like to left join against buckets. So I can identify if a holiday falls within a certain time frame has_holiday. With the following query, I receive a Query error: Query error: LEFT OUTER JOIN cannot be used without a cond…
MySQL: Counting active products that belong to active categories (and optionally to active subcategories)
i’m using MySQL 5.6. I need to get a list of categories, with a product count column. So far, a very easy and trivial task. Here’s where it gets a little complicated: A product has a category, and can also have a subcategory (optionally). Categories, subcategories and products can be active (flg_p…
Oracle SQL group by then sum
I have a table CUST_LOG with data below. How should I select above as below result? I want to group by CUST_ID then sum each status count by CUST_ID? I used OUTER JOIN but not work. The only way I found is use UNION clause as the following sql, but it is too complicated if there are many status. Answer
SQL How to filter table with values having more than one unique value of another column
I have data table Customers that looks like this: I would like to filter the table so that only IDs with more than 1 distinct count of Sequence No remain. Expected output: I tried but I’m getting error. How to solve this? Answer You can get the desired result by using the below query. This is similar to…
How to get all rows from a SQL table before a change in column string?
I have these 2 tables and their inserts: I have this query to partition them by JobId and order them by JobId and StatusDtTm: I want to fetch only the rows where the Job last finished per job. Basically get all the records per job before it last finished (highlighted in green). I can’t seem to figure ou…