Skip to content

Tag: oracle

CUSTOMER and purchased CATEGORY count details in Oracle SQL

I am having the below require. if anyone provide the solution it would be thankful Requirements:- Transaction of the customer who purchased in the below category Customers and purchased Category Total Number of customer from category level category and customer count I want to display the output life below ou…

CASE expression in WHERE clause for diferent and

Can I use case expression to build where like this? I need change where clause depending on the value of x variable. Answer An alternative to using OR is to use nested CASE statements: or you could simplify it to: However, you should check whether Oracle can use column indexes or if a separate function-based …

Transform table to smoothen records in one column

the situation (a real life situation) is: I have a table with “log” records, for simplicity let’s assume there are only columns NAME, TIME, STATE (in reality there are few more). There are cca 1 Milion rows in which there are 100 Names (computers) and cca 10 states (productive, idle, automat…

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 …