Count Distinct on a window
Hello worldI read an article about a measure of viscosity (http://www.seomoz.org/blog/tracking-browse-rate-a-cool-stickiness-metric). It's basically a way to measure how well you attract people to your Web site.
Viscosity for the last 7 days: (County of different users today) / (number of distinct users for the last 7 days)
Viscosity for the last 30 days: (County of different users today) / (number of distinct users for the last 30 days)
I have a table called WC_WEB_VISITS_F that is in the grain of the user's visit to one of my web sites.
Is there a way I can use OBIEE to calculate values above?
I can get the numerator. I create a logical column called count of separate to everyday users and aggregation set to Distinct Count on USER_ID and then I pivot my report to the Date of visit.
I can't understand how Distinct Count for X days. If there were separate count for this month, I just copy the count of distinct daily users and set the content to the month level, however, it is a floating range, I can't do that.
Does anyone have an idea of Cleaver for this?
Thank you!
-Joe
11g is the function PERIODROLLING, which is the answer to all these requirements. The PERIODROLLING function allows you to perform an aggregation on a specified set of periods of grain of query rather than a grain of fixed time series. The most common use is to create rolling averages, as "13-week Rolling average." With 10 all we will get is a feature limited according to solutions...
Tags: Business Intelligence
Similar Questions
-
How to count distinct exclusion of a value in the business layer?
Hi all
I have a column that has a lot of values. I need to do is a measure with aggregator separate count. But I shouldn't count 0 in the column. How can I do that. If I try to use any way to condition the aggregator option is disable. Help, please
Thank youLook at this example:
I did MDB table is DIRTY as:
Count_Distinct_Prod_Id_Exclude_Prod_Id_144
I'll count distinct PRODUCTS. PROD_ID, but exclude PROD_ID = 144 when counting.
Make this measure like this:
1. new column object/logic
2. go in tab data type and click EDIT the table logic table source
3. now, in the general tab add join of a table (in my case of PRODUCTS)
4. go in the column mapping tab-> see the deleted column mapping5. in the new column (in my case Count_Distinct_Prod_Id_Exclude_Prod_Id_144) write similar code:
CASE WHEN "orcl". » ». "" SH ". "PRODUCTS '." "' PROD_ID ' = 144 THEN ELSE NULL"orcl ". » ». "" SH ". "PRODUCTS '." "' PROD_ID ' END6. click OK and close the source logical table
7. now, in the logical column window go to the tab of the aggregation and choose COUNT DISTINCT.8. move the Count_Distinct_Prod_Id_Exclude_Prod_Id_144 measure for presentation
9 test answers (report cointains columns as follows)
PROD_CATEGORY_ID
Count_Distinct_Prod_Id_Exclude_Prod_Id_144And the result in the NQQuery.log is:
Select T21473. PROD_CATEGORY_ID C1,
Count (distinct from cases when T21473.) PROD_ID is 144, then NULL else T21473. End PROD_ID) C2
Of
PRODUCTS T21473
Group of T21473. PROD_CATEGORY_ID
order of c1Concerning
Goran
http://108obiee.blogspot.com -
Count distinct users registered
Hello
I have a table that contains the users and their hours of connection and disconnection. I need to know the maximum number of distinct users connected for a period of 15 minutes for each day. Periods of 15 minutes, start at 00:00 and ends at 23:45
For the above test data, I expect to see:WITH user_data AS (SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 11:57', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 12:34', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 12:18', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 12:23', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 12:41', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 13:20', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 13:22', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 15:12', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 13:25', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 13:26', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER2' user_id, TO_DATE('01-DEC-2010 13:27', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 13:30', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 13:34', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 15:08', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 13:53', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 16:38', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER3' user_id, TO_DATE('01-DEC-2010 14:00', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('22-FEB-2011 14:18', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 14:14', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 15:20', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 14:15', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 15:21', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 14:23', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 15:29', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 14:30', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 19:12', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 14:36', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 15:46', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 14:39', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 16:40', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('01-DEC-2010 14:44', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('01-DEC-2010 16:08', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 09:10', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 12:25', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 09:52', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 13:01', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 10:03', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 13:08', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 10:37', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 11:53', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER2' user_id, TO_DATE('02-DEC-2010 10:40', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 12:01', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 10:54', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 10:59', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 10:55', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 11:02', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 10:59', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 11:00', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER2' user_id, TO_DATE('02-DEC-2010 11:00', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 12:58', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 11:20', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 13:12', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 11:45', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 14:18', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 11:53', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 13:10', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 11:57', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 12:54', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 12:01', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 12:54', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 12:09', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 13:37', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER3' user_id, TO_DATE('02-DEC-2010 12:12', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 12:13', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 12:54', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 15:58', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 13:12', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 13:19', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 13:13', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 15:11', 'DD-MON-YYYY HH24:MI') logout_date FROM dual UNION ALL SELECT 'USER1' user_id, TO_DATE('02-DEC-2010 13:22', 'DD-MON-YYYY HH24:MI') login_date, TO_DATE('02-DEC-2010 13:50', 'DD-MON-YYYY HH24:MI') logout_date FROM dual), pivs AS (SELECT 0 piv_num FROM dual UNION ALL SELECT 1 piv_num FROM dual UNION ALL SELECT 2 piv_num FROM dual UNION ALL SELECT 3 piv_num FROM dual UNION ALL SELECT 4 piv_num FROM dual UNION ALL SELECT 5 piv_num FROM dual UNION ALL SELECT 6 piv_num FROM dual UNION ALL SELECT 7 piv_num FROM dual UNION ALL SELECT 8 piv_num FROM dual UNION ALL SELECT 9 piv_num FROM dual UNION ALL SELECT 10 piv_num FROM dual UNION ALL SELECT 11 piv_num FROM dual UNION ALL SELECT 12 piv_num FROM dual UNION ALL SELECT 13 piv_num FROM dual UNION ALL SELECT 14 piv_num FROM dual UNION ALL SELECT 15 piv_num FROM dual UNION ALL SELECT 16 piv_num FROM dual UNION ALL SELECT 17 piv_num FROM dual UNION ALL SELECT 18 piv_num FROM dual UNION ALL SELECT 19 piv_num FROM dual UNION ALL SELECT 20 piv_num FROM dual UNION ALL SELECT 21 piv_num FROM dual UNION ALL SELECT 22 piv_num FROM dual UNION ALL SELECT 23 piv_num FROM dual UNION ALL SELECT 24 piv_num FROM dual UNION ALL SELECT 25 piv_num FROM dual UNION ALL SELECT 26 piv_num FROM dual UNION ALL SELECT 27 piv_num FROM dual UNION ALL SELECT 28 piv_num FROM dual UNION ALL SELECT 29 piv_num FROM dual UNION ALL SELECT 30 piv_num FROM dual UNION ALL SELECT 31 piv_num FROM dual UNION ALL SELECT 32 piv_num FROM dual UNION ALL SELECT 33 piv_num FROM dual UNION ALL SELECT 34 piv_num FROM dual UNION ALL SELECT 35 piv_num FROM dual UNION ALL SELECT 36 piv_num FROM dual UNION ALL SELECT 37 piv_num FROM dual UNION ALL SELECT 38 piv_num FROM dual UNION ALL SELECT 39 piv_num FROM dual UNION ALL SELECT 40 piv_num FROM dual UNION ALL SELECT 41 piv_num FROM dual UNION ALL SELECT 42 piv_num FROM dual UNION ALL SELECT 43 piv_num FROM dual UNION ALL SELECT 44 piv_num FROM dual UNION ALL SELECT 45 piv_num FROM dual UNION ALL SELECT 46 piv_num FROM dual UNION ALL SELECT 47 piv_num FROM dual UNION ALL SELECT 48 piv_num FROM dual UNION ALL SELECT 49 piv_num FROM dual UNION ALL SELECT 50 piv_num FROM dual UNION ALL SELECT 51 piv_num FROM dual UNION ALL SELECT 52 piv_num FROM dual UNION ALL SELECT 53 piv_num FROM dual UNION ALL SELECT 54 piv_num FROM dual UNION ALL SELECT 55 piv_num FROM dual UNION ALL SELECT 56 piv_num FROM dual UNION ALL SELECT 57 piv_num FROM dual UNION ALL SELECT 58 piv_num FROM dual UNION ALL SELECT 59 piv_num FROM dual UNION ALL SELECT 60 piv_num FROM dual UNION ALL SELECT 61 piv_num FROM dual UNION ALL SELECT 62 piv_num FROM dual UNION ALL SELECT 63 piv_num FROM dual UNION ALL SELECT 64 piv_num FROM dual UNION ALL SELECT 65 piv_num FROM dual UNION ALL SELECT 66 piv_num FROM dual UNION ALL SELECT 67 piv_num FROM dual UNION ALL SELECT 68 piv_num FROM dual UNION ALL SELECT 69 piv_num FROM dual UNION ALL SELECT 70 piv_num FROM dual UNION ALL SELECT 71 piv_num FROM dual UNION ALL SELECT 72 piv_num FROM dual UNION ALL SELECT 73 piv_num FROM dual UNION ALL SELECT 74 piv_num FROM dual UNION ALL SELECT 75 piv_num FROM dual UNION ALL SELECT 76 piv_num FROM dual UNION ALL SELECT 77 piv_num FROM dual UNION ALL SELECT 78 piv_num FROM dual UNION ALL SELECT 79 piv_num FROM dual UNION ALL SELECT 80 piv_num FROM dual UNION ALL SELECT 81 piv_num FROM dual UNION ALL SELECT 82 piv_num FROM dual UNION ALL SELECT 83 piv_num FROM dual UNION ALL SELECT 84 piv_num FROM dual UNION ALL SELECT 85 piv_num FROM dual UNION ALL SELECT 86 piv_num FROM dual UNION ALL SELECT 87 piv_num FROM dual UNION ALL SELECT 88 piv_num FROM dual UNION ALL SELECT 89 piv_num FROM dual UNION ALL SELECT 90 piv_num FROM dual UNION ALL SELECT 91 piv_num FROM dual UNION ALL SELECT 92 piv_num FROM dual UNION ALL SELECT 93 piv_num FROM dual UNION ALL SELECT 94 piv_num FROM dual UNION ALL SELECT 95 piv_num FROM dual UNION ALL SELECT 96 piv_num FROM dual UNION ALL SELECT 97 piv_num FROM dual UNION ALL SELECT 98 piv_num FROM dual UNION ALL SELECT 99 piv_num FROM dual) SELECT s2.cdate, MAX(s2.user_count) FROM (SELECT TO_CHAR(t.cdate, 'DD-MON-YYYY') cdate, SUM(LEAST(t.user_count, 1)) user_count FROM (SELECT TO_DATE('01-DEC-2010', 'DD-MON-YYYY') + p1.piv_num cdate, TO_CHAR(TO_DATE((p2.piv_num * 15) * 60, 'SSSSS'), 'HH24:MI') time, SUM(CASE WHEN TRUNC((TO_DATE('01-DEC-2010', 'DD-MON-YYYY') + p1.piv_num) + (p2.piv_num * 15)/1440, 'MI') BETWEEN s.login_date and s.logout_date THEN 1 ELSE 0 END) user_count FROM pivs p1, pivs p2, (SELECT user_id, login_date, logout_date FROM user_data) s WHERE p1.piv_num < 2 -- number of days I want to look at i.e. 01-DEC-2010 and 02-DEC-2010 AND p2.piv_num < 96 -- number of 15 minute periods in a day i.e. 00:00 to 23:45 GROUP BY p1.piv_num, p2.piv_num, s.user_id ORDER BY p1.piv_num, p2.piv_num) t GROUP BY t.cdate, t.time) s2 GROUP BY s2.cdate ORDER BY TO_DATE(s2.cdate) /
The code above works, but I'm sure there must be a better way to do it, I can't see how...Date Users ----------- ----- 01-DEC-2010 2 02-DEC-2010 3
LeeHello
Here's one way:
WITH parameters AS ( SELECT TO_DATE ( '01-Dec-2010' -- Starting time (included in output) , 'DD-Mon-YYYY' ) AS start_dt , TO_DATE ( '03-Dec-2010' -- Ending time (NOT included in output) , 'DD-Mon-YYYY' ) AS end_dt , 24 * 4 AS periods_per_day FROM dual ) , periods AS ( SELECT start_dt + ((LEVEL - 1) / periods_per_day) AS period_start , start_dt + ( LEVEL / periods_per_day) AS period_end FROM parameters CONNECT BY LEVEL <= (end_dt - start_dt) * periods_per_day ) , got_cnt_per_period AS ( SELECT p.period_start , COUNT (distinct user_id) AS cnt , ROW_NUMBER () OVER ( PARTITION BY TRUNC (period_start) ORDER BY COUNT (*) DESC , period_start ) AS rnk FROM periods p JOIN user_data u ON p.period_start <= u.logout_date AND p.period_end > u.login_date GROUP BY p.period_start ) SELECT period_start , cnt FROM got_cnt_per_period WHERE rnk = 1 ORDER BY period_start ;
You will notice that it does not use the pivs table. Generate periods of time with a CONNECT BY query is likely to be more effective, and you don't have to worry about having enough rows in the table pivs.
In this way avoids also all conversions between DATEs and strings (except for the entrance of the start_dt and end_dt parameters), which should take some time.If you are actually hardcode the parameters in the query, the abopve version will be easier to use and maintain, because each parameter only has to register once, in the first auxiliary request.
The output includes the start time of the period who had the highest number on each day. If there are equal (as in this example of data, there were 3 periods December 1, which had a number of 2), then the specified period is that earlier that day. If you want to see all, replace ROW_NUMBER RANK by the last auxiliary request, got_cnt_per_peroid. Of course, you don't have to display the time if you do not want.
-
OVERALL TOTAL incorrect (with COUNT DISTINCT)
Hello
I get incorrect results in a DISTINCT COUNT measure column GRAND TOTAL.
I have 5 separate in Paris and 10 separate clients in New York, I want the grand total for the sum of the two, it is 15.
But OBIEE calculates separate customers for all cities, so if there are customers in Paris and New York, the result is false.
This is the result I get:
City Number_Distinct_Customers
----------------------------------------------------------------------------
Paris 5
NEW YORK CITY 10
GRAND TOTAL 12
12 is the number of all separate clients.
The correct GRANT TOTAL is expected to be 5 + 10 = 15
Thank you
ConcerningI guess that COUNT(DISTINCT...) is regarded as the default aggregation in the Oracle replies.
To come in this, change the State of aggregation of fx (formula column in the criteria of answers tab) to 'SUM '...Let me know if that solves your problem.
-bifacts :-)
http://www.obinotes.com -
COUNT (DISTINCT <; nom_de_colonne >;)
I would like to display the count (DISTINCT < company >) at the end of the report. I use a SQL query in the form of data / the whole model. Thanks in advance.
NEW YORK CITY
JANUARY 1, 2008
Company ID DIFF
ABC 1-1
2 2 XYZ
ABC 3-1
FEBRUARY 1, 2008
Company ID DIFF
MNO 1-1
2 2 XYZ
MNO 3-1
Total number of companies: 3Use this
-
What is the difference between the meter and the meter separate in the advanced INTERFACE
Operations-> all settings-> deployed-> Count?
This metric is available in the advanced user interface and the custom user interface. Measures are not read in the Admin UI.
Distinct count is the actual number of virtual machines deployed, while the County is # trend / forecasting of the deployed virtual machines. Usually, you will notice the separate account doesn't have a very clear dynamic threshold, but the County has a dynamic rise. Speaking of which, I would say probably a couple more VMs to meet forecasts of my lab... ha.
-
Maximum, Count Distinct functions in the model.
Hello
I have a set of data that I tried to regroup for a report.
I need in the report so that I have product code list in a column and Max (Product Code) in another column product code, product code Sub are strings and not numbers.
Suppose that my data set has
product code:-product-sub-code
____________________________
ABC | 1A
ABC | 1 b
ABC | 1 c
def | 1 B
def | 2B
def | 2 c
...
...
....
...
...
I need to report
ABC | 1A
def | 2B
..
I gathered it and I tried to show the Max (product code) for the current group. But it gave me a number instead of text. I tried to select 'text' to the form field. But it is automatically change the number.
Also, can you let me know how to write the number (code of separate by-product). I must also add that column.
I can't add in SQL because there are tons of models on this data set. I have to do it in the model.
Any help is greately appreciated.Try using this: -substitute your domain under product code name
Thank you
Bipuser -
I counted 99 updates to Windows XP, Explorer 10 ea.Netframework3.0 Service Pack 13 c., Net framework as MS Framework 2.0 1.1 has 15 updates. All this can I? I think that I have disabled the new notifications on updates, how can I check to see if I am up to date?
You must know if you turned off to THE or not probably.
HOW to: Configure and use automatic updates in Windows XP
http://support.Microsoft.com/kb/306525Once you turn on to THE, then go and manually check the updates are applicable to your computer, including optional updates.
In regards to the framework, if a program requires the Framework will advise you.
Benefits of Microsoft .NET Framework
http://support.Microsoft.com/kb/829019TaurArian [MVP] 2005-2011 - Update Services
-
Distinct count in the instruction box
-------------------------------------------------------------------------------------------------
SELECT A.P_ID,
B.P_NAME,
C.P_DESC,
SUM (CASE
WHEN A.DATE BETWEEN TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE),-4) + 1) AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)),-1)
AND A.M_ID IS NOT NULL
THEN 1
0 OTHERWISE
END) AS COUNT,
SUM (CASE
WHEN A.DATE BETWEEN TRUNC (ADD_MONTHS (LAST_DAY (SYSDATE),-4) + 1) AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)),-1)
AND A.M_ID IS NOT NULL
THEN COUNT (DISTINCT A.M_ID)
0 OTHERWISE
END) AS UNIQUE_COUNT, / * is not possible * /.
SUM (CASE
WHEN A.DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)), - 1).
THEN A.AMT_1
0 OTHERWISE
END) AS TOTAL_AMT_1,
SUM (CASE
WHEN A.DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND ADD_MONTHS (LAST_DAY (TO_DATE (SYSDATE)), - 1).
THEN A.AMT_2
0 OTHERWISE
END) AS TOTAL_AMT_2
FROM TABLE_A A,.
TABLE_B B,.
C TABLE_C
WHERE A.P_ID = B.P_ID
AND B.PT_ID = C.PT_ID
A.P_ID GROUP,
B.P_NAME,
C.P_DESC
----------------------------------------------------------------------------------------------------------
Hello
It is a simplified version of my request.
I'm doing 4 things here,
1. the County A.M_ID
2 County has separate .M_ID, is where I have a problem.
3 and 4. It is just the sum of 2 diff columns.
Note that the dates for the County and the amt are different and I can't hard-code the.
Can someone help me step of distinct count?
This query runs also a bit slow.
So all suggestions, comments are welcome.
Note: TABLE_A REB 700 million, TABLE_B 4 million and TABLE_c is located only 500 RECS
Thank you!Advantage of the fact that aggregate functions more ignore nulls, you could do something like:
SELECT a.p_id, b.p_name, c.p_desc, COUNT(CASE WHEN a.date BETWEEN TRUNC(ADD_MONTHS(LAST_DAY(sysdate),-4) + 1) AND ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) AND a.m_id IS NOT NULL THEN m_id END) AS countall, COUNT(DISTINCT CASE WHEN a.date BETWEEN TRUNC(ADD_MONTHS(LAST_DAY(sysdate),-4) + 1) AND ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) AND a.m_id IS NOT NULL THEN a.m_id END) AS unique_count, /* entirely possible */ SUM(CASE WHEN a.date BETWEEN TRUNC(sysdate,'YEAR') AND ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) THEN a.amt_1 ELSE 0 END) AS total_amt_1, SUM(CASE WHEN A.DATE BETWEEN TRUNC(sysdate,'YEAR') AND ADD_MONTHS(LAST_DAY(TO_DATE(sysdate)),-1) THEN A.AMT_2 ELSE 0 END) AS TOTAL_AMT_2 FROM table_a a, table_b b, table_c c WHERE a.p_id = b.p_id and b.pt_id = c.pt_id GROUP BY a.p_id, b.p_name, c.p_desc
The two statements inside the COUNTY box return a.m_id or NULL. A simplified test case is:
SQL> WITH t as ( 2 SELECT 1 m_id, 9 dt FROM dual UNION ALL 3 SELECT 1 m_id, 6 dt FROM dual UNION ALL 4 SELECT 2 m_id, 9 dt FROM dual UNION ALL 5 SELECT 2 m_id, 6 dt FROM dual UNION ALL 6 SELECT 1 m_id, 5 dt FROM dual UNION ALL 7 SELECT 2 m_id, 5 dt FROM dual UNION ALL 8 SELECT null m_id, 9 dt FROM dual) 9 SELECT count(CASE WHEN dt BETWEEN 6 and 9 THEN m_id end) cid, 10 count(distinct CASE WHEN dt BETWEEN 6 and 9 THEN m_id end) cdid 11 FROM t; CID CDID ---------- ---------- 4 2
I'm not entirely sure that you really need the IS NOT NULL predicate a.m_id in the instructions BOX, but I left it for more security.
John -
How to count the total number of records with distinction?
Hello guys
I have a report that contains a list of the types of company and other attributes as follows:
The list goes on and... "Business type" appears is not the highest or the lowest... I would like to see what is the total number of different company types we have. By this report, there should be 5, but if I count or count (*) or rcompte, I actually get the total number of lines in the present report, which is not what I want...Shipto Company Type GC Code Measures A cc x 100 y 200 c 120 B YUT I 200 cc U 98 G Maid rt 200 YUT TT 300 JTE TY 400
If someone could help me to find the total number of company types?
Thanks in advanceHave you tried this one?
Sum (Count (distinct ColumnName))
-
Getting Sum, Count, and Distinct Count of a file
Hi all, this is a question of UNIX.
I have a large flat file with millions of records.
col1 | col2. col3
1. a | b
2. c | d
3. e | f
3. g | h
footer *.
I'm supposed to do to calculate the sum of the [= 9] col1 col1 County [= 4] and a separate account of col1 [= c3]
I would like if you avoid external commands like AWK. Also, can we do the same thing by creating a function?
Please keep in mind that the file is huge
Thanks in advanceYes, I suppose that it is very much inappropriate for answering this question here, I just like awk too] :))
where x is the file:
sum(col1) : awk -F\| '{col1+=$1}END{print col1}' x count(col1): wc -l x | awk '{print $1-2}' count(distinct col1): cut -d\| -f1 x|sort -u|wc -l|awk '{print $1-2}'
Perl would be a much more effective tool to use here... try a perl forum :)
-
rolliing backword window. How to calculate and op like this
I have date as below
How can I achieve this.with abc as (select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 216 ilo_id, to_date('06/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 215 ilo_id, to_date('05/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 214 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 213 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 212 ilo_id, to_date('03/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 211 ilo_id, to_date('02/01/2009', 'dd/mm/yyyy') i_date from dual) select * from abc USERID CLO_ID C_DATE ILO_ID I_DATE 1 11 05/01/2009 00:00:00 216 06/01/2009 00:00:00 1 11 05/01/2009 00:00:00 215 05/01/2009 00:00:00 1 11 05/01/2009 00:00:00 214 04/01/2009 00:00:00 1 11 05/01/2009 00:00:00 213 04/01/2009 00:00:00 1 11 05/01/2009 00:00:00 212 03/01/2009 00:00:00 1 11 05/01/2009 00:00:00 211 02/01/2009 00:00:00 Now i want to calculate rolling backword frequency of each ilo id and output should come like as based Frequency winodw e.g. if frequency window is 2 then USERID CLO_ID C_DATE ILO_ID I_DATE FREQUENCY 1 11 05/01/2009 00:00:00 216 06/01/2009 00:00:00 2 1 11 05/01/2009 00:00:00 215 05/01/2009 00:00:00 3 1 11 05/01/2009 00:00:00 214 04/01/2009 00:00:00 3 1 11 05/01/2009 00:00:00 213 04/01/2009 00:00:00 2 1 11 05/01/2009 00:00:00 212 03/01/2009 00:00:00 2 1 11 05/01/2009 00:00:00 211 02/01/2009 00:00:00 1 1. For each ILO ID, go back number od days given as Frequency window (in our case its 2) 2. calculate the number of ilo_id in that range 3. number of ilo_id is the frequency of that ilo_id
Published by: Kuldeep2 on September 29, 2010 02:30
Published by: Kuldeep2 on September 29, 2010 02:33with abc as (select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 216 ilo_id, to_date('06/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 215 ilo_id, to_date('05/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 214 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 213 ilo_id, to_date('04/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 212 ilo_id, to_date('03/01/2009', 'dd/mm/yyyy') i_date from dual union all select 1 userid, 11 clo_id, to_date('05/01/2009', 'dd/mm/yyyy') c_date, 211 ilo_id, to_date('02/01/2009', 'dd/mm/yyyy') i_date from dual) select abc.*, ( select count(distinct ilo_id) from abc x where x.i_date between abc.i_date - ( :frequency_window - 1 ) and abc.i_date and ( (x.i_date=abc.i_date and x.ilo_id<=abc.ilo_id) or (x.i_date
My last try. I changed the condition for counting again (see code).
-
Install Win 7 hangs after "install updates" starting windows
Re-installing win7 Professional 64 bit on a computer hp laptop. You had to make a record of killing to eliminate the problem. Previous installation went smooth. All files transfer and expand, all the way to the installation of updates. Then it counts down to restart windows. Then nothing.
Hello
I suggest that you try to perform the boot repair and check if this can help:
http://Windows.Microsoft.com/en-us/Windows7/Startup-Repair-frequently-asked-questions
It will be useful.
-
missing in Windows 7 desktop calendar.
I was counting a lot on Windows desktop calendar that I had with Vista. My current computer runs on Windows 7, which doesn't seem to have a Windows desktop calendar. Is there a download available Windows that provides an interactive desktop calendar, or one that can be downloaded for free from another reliable source?
There is a calendar gadget, if that's what you're looking for. Just right click on an empty space on the right side of your screen and click gadgets. On the desktop, and then drag the calendar.
Windows Live Mail has a calendar.
And if you click on the digital clock in the lower right corner of your screen, you'll see a calendar there as well.
I hope this helps. Good luck.
-
Windows 7 Theme is changing automatically to "unsaved theme".
OK so I am running Windows 7 on a almost new ASUS K50IJ and my problem is with the customization, more precisely defining a theme/desktop background. When I change my theme and save it and delete all the other themes everything works very well, exactly as I want. The problem is when I shut down my computer, and then start it upward, the theme has magically changed back to a theme "non-registered" with a completely different environment than what I chose.
Ive been reading forums all day and tried some things listed there, but did not get anything to work properly. This is driving me CRAZY and I need it fixed. STAT. Also, I don't know if it's relevant or not, but a lot forums that I met, people with computers ASUS have been encountering this problem. I wonder if it is a software that comes standard on the ASUS computers that is counter the themes of Windows 7. Just a thought.
Hi Ashley,
Try the suggestions given here.
http://windows7themes.NET/Windows-7-unsaved-theme-bug.html
Maybe you are looking for
-
Web sites like murraystivoli.com that display the facebook and twitter icons and in particular the new Yahoo Mail interface fail to display the icons. I see only a small rectangle. On Yahoo Mail, there are a few inside but instead it should be the di
-
Error message indicator of battery at startup
HP Pavilion p6512uk desktop running Windows 7 64 bit PC Whenever I boot, I get the following two messages: Battery indicator - HPID09. Access violation at address 00401C 62 in the module 'BATINDICATOR' read of address 000002DC .exe and Battery indic
-
How can I set a deadband for PID regulation
When I use a PID. VI to set pressure, when the PV nearby OAS, I want the PID.vi hold its output, but I have no idea to set the parameters of dead zone! (can not find the definition of dead zone) An engineer PLC said that the dead zone is a common par
-
EliteBook 8740w: core peripheral system problem
It is under the properties of my base system device PCI VEN_1180 & DEV_0843 & SUBSYS_1520103C & REV_14PCI VEN_1180 & DEV_0843 & SUBSYS_1520103CPCI VEN_1180 & DEV_0843 & CC_088000PCI VEN_1180 & DEV_0843 & CC_0880 Deiver does not load The drivers for t
-
MAX problems: Connection and conversion
We live another problem with NI MAX. We have Lookout 5.1 and 6.2 on a stand alone and a Virtual Machine, both with the same problem. When you attach a database, we select the 4 Citadel, the wizard opens. By clicking Browse results in closing the w