Skip to content
Advertisement

Tag: count

SQL to find local count max per primary key

I have a table with PK CustomerId + type. Each customer has a few types. For each customer I want to get type which repeated the most for this customer. I’ve tried to create a column “count” but I want to get the local maxs, and not a global max for the whole col. Is there a native way to

How do I aggregate data in sql for multiple rows of data by column name?

hi im new to sql and trying to understand how to work with data structures. I have a table If the interaction userkey number repeats then, i want a column called number of visits. in this case, for interactionuserkey 5, there are 2 total visits since its repeated twice. for interactionuserkey 0, number of visits =1 and so on. Basically,

How to get distinct parent_sku count for the below dataset?

Need your help to extract distinct Parent_sku count from the below data set. Condition: If one child of a parent_sku has “High” sales_tag then that parent_sku count should be excluded from “Low” sales_tag. P.S. Sales_tag column is based on child_sku column. Thank you for your help. Dateset_&_Output Answer The presented schema is non-conducive to this type of query, however we

Oracle SQL Count function

I am hoping someone can advise on the below please? I have some code (below), it is pulling the data I need with no issues. I have been trying (in vain) to add a COUNT function in here somewhere. The output I am looking for would be a count of how many orders are assigned to each agent. I tried

MySQL customized exists query performance

Because of using Hibernate, I cannot write a JPA query using exists like this (I translated it to pure SQL query): So I have to write an alternative query to check existance of activated accounts. After reading several suggestions on this website, I see a replacement: My question is: Is this bad for performance, is it short circuit query. Means

Advertisement