DISTINCT
3 TopicsNeed help with an SQL query without using a cursor
Hi there to all SQL gurus So, here is the scenario. I have a #temp table in one of my SQL stored procedures which has only 2 columns, say Customer ID and Profile ID, and it has the below data Customer ID Profile ID 100001 ABCD001 100001 ABCD002 100002 ABCD001 100002 ABCD002 100003 ABCD001 I need to write a query which selects only the Profile ID which is mapped to all the Customer IDs. In this case Customer ID 100001 and 100002 have both ABCD001 and ABCD002, but Customer ID 100003 has only Profile ID ABCD001, so, the output of the SQL should have only ABCD001. How do I do this without using a CURSOR? Would a CTE help? I am not very familiar with CTE, so if the solution is using a CTE, please give your suggestions in more detail. Thanks in advance29Views0likes1CommentCalculating distinct counts in Power BI with data in Kusto
Distinct counts using the dcount KQL function return estimated values. A new setting in Ower BI allows you to control how accurate (and how expensive) these counts will be You can also choose to use the new count_distinct function which return exact numbers but can be very expensive.3.9KViews0likes1CommentAdd Column Using Count
I am trying to add a column named Past12 to my table wynne_incidents. I want to count all the distinct incident_num by employ_id. So basically, I am counting the number of incidents (incident_num) for each employee (employ_id). I have this query which pulls the data correctly. Now I just need to know how to use it with ALTER TABLE and ADD select count(distinct incident_num)as "Past 12", employ_id from wynne_incidents where inc_date >= '04/01/2019' and inc_date <= '06/30/2019' group by employ_id Thank you!5.1KViews0likes0Comments