Skip to content

Select single value from same columns based on condition

I have below table and using oracle sql Result Question : Need query to get it. I have Tried MAX but not working Answer Assuming these are the only three conditions, you can use conditional aggregation: In Oracle, you can simplify this to: Here is a db<>fiddle. The keep syntax is getting the last value …

Questions on aggregation

I am required to find the name of the product (iname) where total delivery quantity is equal to the total sales quantity Two tables given are I tried this code but the result I got is aggregated incorrectly because there are multiple sales and deliveries of the same item When I do the following I was able to …

Datediff on 2 rows of a table with a condition

My data looks like the following Now, I want to calculate the datediff between the closeddates for teams A, and B, if the max closeddate for team A is greater than max closeddate team B. If it is smaller or null I don’t want to see them. So, for example,I want to see only one record like this : and

Convert day of year to date using proc sql in SAS

I have a day of year column and need to convert it to a date.I want to find the exact date that the insurance coverage began for every person. I also have a year column Have data: Want data: I searched up and find that the following command works in Oracle sql but does not work in SAS sql I

How to compose query properly using dbGetQuery command?

I have a small database in PostgresSQL. And I connected to it via R-studio and try to retrieve data from database. I wrote a command, but it doesn’t work. And I don’t know what’s the problem. Please, help me. So, the code works well. But these two codes fail Where con is the postgres connect…