Count distinct records
Hi All,
I have one table like
App_Code --- App_ID --- SEQ_ID
C0---------------- 001----------------0
U0--------------- 001----------------6
F1---------------- 001----------------26
C0-------------- 002----------------0
C0-------------- 003----------------0
U0-------------- 003----------------6
F6-------------- 003----------------27
I want to get the result where app_id (001) match all code .. means C0/U0/F1.. it means application approved and give me the count 1.. there will be no count of app_id (002 or 003)... because its not met the criteria of C0/U0/F1
I hope I explained it well
With much appreciation,
Riz
Edited by: [email protected] on Apr 4, 2010 12:26 PM
Hi,
I've an query structured like this, but containing also a date column. I want to group by date, and want to leave out time. Only group by day. How can I do this?
When I try to use to_date, to_char or trunc in the group by clause I got the error messagen:
QL Error: ORA-00979: "not a GROUP BY expression"
My query:
SELECT trunc(v_date,'dd'),
COUNT (CASE WHEN sender = 'A' AND receiver = 'M' AND message_type = 'O THEN 1 END) AS A,
COUNT (CASE WHEN sender = 'C' AND receiver = 'M' AND message_type = 'O' THEN 1 END) AS C ,
COUNT (CASE WHEN sender = 'F' AND receiver = 'M' AND message_type = 'I' THEN 1 END) AS F ,
COUNT (CASE WHEN sender = 'I' AND receiver = 'M' AND message_type = 'O' THEN 1 END) AS I ,
COUNT (CASE WHEN sender = 'M' AND receiver = 'M' AND message_type = 'O' THEN 1 END) AS M
FROM v_search_m
WHERE v_date > sysdate-30 GROUP BY trunc (v_date,'dd') ORDER BY v_date desc
Br, Hanne
Similar Messages
-
Count distinct aggregation in CWM2
Hi,
Is there any way to make a count distinct aggregation with a CWM2 model?
I mean, for the documentation example (geography, product, channel and time dimensions), I would like to show in a graph the sum of the sales measure and the number of different products, for the different filter selections made.
E.g.:
Page items: geography dim, time dim.
Groups: Measures (sales measure, ¿number of different products?)
Series: channel dim.
I know that the unique possible aggregation in CWM2 model is SUM, so I think it can't be done with an aggregation. Can anyone suggest me a workaround to do this? Is it possible within an analytical workspace?
Thanks in advanced...Hi Nagarajan,
1. have to count distinct records from one internal ta
first of all u have to decide
which FIELD COMBINATION makes a record unique.
2. After that u can use the abap syntax
delete adjacent duplicates (see documention/help)
(before this make sure to SORT the internal table
in the same sequence of FIELD COMBINATION)
3. then u can use
describe table itab.
4. Before doing step 2,
u can copy the whole internal table to another internal table
and do your logic on the second internal table
so that the original is not lost.
u can copylike this.
ITAB2[] = ITAB1[].
Hope it helps.
Regards,
Amit M.
Message was edited by: Amit Mittal -
Heres my situation:
Table a has rows like this
Col1 Col2 Col3
1 1 feb-1999
1 1 feb-1999
2 1 feb-1999
2 1 feb-1999
3 2 mar-1999
4 4 mar-1999
What i need to return is a count of the distinct occurances of col1 and col2 grouped by month. So given thabove data my resulting set should be
Count Month
2 feb-1999
2 mar-1999
Thanks,
Allen...I think it'd better adding a non-numeric character (e.g. space character) to separate the value strings of col1 and col2 . That is,
select count(distinct to_char(col1)| |' '| |to_char(col2)),
to_char(col3,'mon-yyyy')
from test1
group by to_char(col3,'mon-yyyy');
Cheers/RS
null -
"group by" slow for using "count(distinct some_column)" - a better way?
Hi all,
i have an
select
count(distinct some_column),
from [...]
group by [...];
Which is slowed down for the "*count(distinct some_column)*".
The "group by" aggregates base records.
But the base records have 1:n for some #1 event #n records each.
Some of the #n records fall into group by result record (A), some other into group by result record (B).
But each shall only count +1 per event - disregarding how many of the #n record have fallen into that category.
Is there another (faster) way to count for this?
- thanks!
best regards,
Frank
Edited by: user8704911 on Jun 29, 2011 1:30 AMHi Dom,
incidentally i went in the direction you proposed:
I replaced the pl/sql collection with the global temporary table.
But the reason for doing this was a different one:
I recognized, that the group by is much faster, if applied on table or global temporary table.
However i first just moved the data from pl/sql collection to global temporary table in order to apply the group by there.
Then the group by is much faster - but the moving of data from pl/sql collection to global temporary table then took away the time.
So it was not the group by, but in general the read-access to the pl/sql collection (btw, around #65,000 records).
Now having completely replaced the pl/sql collection with global temporary table everything is fine.
cheers,
Frank -
Hi everyone,
An analyst on my team heard of a new metric called a "Stickiness" metric. It basically measures how often users are coming to your website overtime.
The definition is as follows:
# Unique Users Today/#Unique users Over Last 7 days
and also
# Unique Users Today/#Unique users Over Last 30 days
We have visit information stored in a table W_WEB_VISIT_F. For the sake of simplicity say it has columns VISIT_ID, VISIT_DATE and USER_ID (there are several more dimensional columns it has but I want to keep this exercise simple).
I want to create an aggregate table called W_WEB_VISIT_A that pre-aggregates the three values I need per day: # Unique Users Today, #Unique users Over Last 7 days and #Unique users Over Last 30 days. The only way I can think of building the aggregate table is as follows
WITH AGG AS (
SELECT
VISIT_DATE,
USER_ID
FROM W_WEB_VISIT_F
GROUP BY
VISIT_DATE,
USER_ID
select
VISIT_DATE
COUNT(DISTINCT USER_ID) UNIQUE_TODAY,
(select count(distinct hist.USER_ID) from agg hist where hist.VISIT_DATE between src.VISIT_DATE - 6 and src.VISIT_DATE) SEVEN_DAYS,
(select count(distinct hist.USER_ID) from agg hist where hist.VISIT_DATE between src.VISIT_DATE - 29 and src.VISIT_DATE) THIRTY_DAYS
from agg
group by visit_date
The problem I am having is that W_WEB_VISIT_F has several million records in it and I can't get it the above query to complete. It ran over night and didn't complete.
Is there a fancy 11g function I can use to do this for me? Is there a more efficient method?
Thanks everyone for the help!
-Joe
Edited by: user9208525 on Jan 13, 2011 6:24 AM
You guys are right. I missed the group by I had in the WITH Clause.Hi,
Haven't used the windowing clause a lot, so I wanted to give a try.
I made up some data with this query :create table t as select sysdate-dbms_random.value(0,10) visit_date, mod(level,5)+1 user_id
from dual
connect by level <= 20;Which gave me following rows :Scott@my10g SQL>select * from t order by visit_date;
VISIT_DATE USER_ID
03/01/2011 13:17:10 1
04/01/2011 05:30:30 4
04/01/2011 08:08:13 5
04/01/2011 14:42:24 3
04/01/2011 20:20:58 3
05/01/2011 17:29:24 2
05/01/2011 17:40:20 4
05/01/2011 18:32:56 2
06/01/2011 04:12:53 5
06/01/2011 08:59:18 2
06/01/2011 09:04:26 3
06/01/2011 10:14:20 1
06/01/2011 14:22:54 1
06/01/2011 19:39:04 1
08/01/2011 14:44:18 5
08/01/2011 21:38:04 5
11/01/2011 04:56:05 4
11/01/2011 18:52:29 2
11/01/2011 23:57:30 4
13/01/2011 07:24:22 3
20 rows selected.I came up to that query :select
v.*,
case
when unq_l3d is null then -1
else trunc(unq_today/unq_l3d,2)
end ratio
from (
select distinct trcdt, unq_today, unq_l3d
from (
select
trcdt,
count(user_id)
over (
order by trcdt
range between numtodsinterval(1,'DAY') preceding and current row
) unq_today,
count(user_id)
over (
order by trcdt
range between numtodsinterval(3,'DAY') preceding and current row
) unq_l3d
from (
select distinct trunc(visit_date) trcdt, user_id from t
) v
order by trcdtWith my sample data, it gives me :TRCDT UNQ_TODAY UNQ_L3D RATIO
03/01/2011 00:00:00 1 1 1.00
04/01/2011 00:00:00 4 4 1.00
05/01/2011 00:00:00 5 6 0.83
06/01/2011 00:00:00 6 10 0.60
08/01/2011 00:00:00 1 7 0.14
11/01/2011 00:00:00 2 3 0.66
13/01/2011 00:00:00 1 3 0.33
7 rows selected.where :
- UNQ_TODAY is the number of distinct user_id in the day
- UNQ_L3D is the number of distinct user_id in the last 3 days
- RATIO is UNQ_TODAY divided by UNQ_L3D +(when UNQ_L3D is not zero)+
It seems quite correct, but you would have to modify the query to fit to your needs and double-check the results !
Just noticed that my query is all wrong*... must have been missing coffeine, or sleep.... but I'm still trying !
Edited by: Nicosa on Jan 13, 2011 5:29 PM -
OLAP Analysis Count Distinct?
If this query is better suited to the OLAP forum, please let me know.
I am creating an Enrollment cube that has a dimension of Student with a Student_ID attribute. The fact table contains a measure column called Students, with each record having a value of 1. This results in getting a total SUM of students for a specific semester in an analysis in BI. However, this SUM aggregation does not distinctly identify students, resulting in a student that attends 4 semesters being counted as 4 students for the entire academic year. Adding COUNT(DISTINCT Student.Student_ID) to the analysis worked with an earlier test cube that I had created, but when I try to perform it on my updated cube it will only give me a COUNT(DISTINCT) for All Time, even when looking at the Semester or Academic Year levels. The only appreciable difference in my updated cube is that it has more dimensions.Yes, you can post your query on the OLAP forum because this forum is on Oracle BI Applications (pre packages applications using OBEE + DAC + Informatica).
Regards,
Benoit -
Count distinct from a master table and sum from a detail
Hello to all,
I have a query like as:
select a,b,c, SUM(fa.ip1) S1, SUM(fa.ip2) S2
FROM tab1 FI, tab2 FA
where fi.x1 = fa.x1
and fi.x2 = fa.x2
group by a,b,c;
tab1's table is master table for tab2's table (one tab1 records there are many tab2 records), (one to many relation)
My question is, how can I get to sum of columns: ip1 and ip2 from tab2 Fa, with only count(how many) of rows of tab1?
Somethings similar to;
Select a,b,c, count(distinct fi.x1, fi.x2 ) nrec_of_FI, SUM(fa.ip1)S1, SUM(fa.ip2) S2
Thanks in advanceHi,
Sorry, I can't tell what you want just by looking at code that does not do it.
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using (for example, 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Perhaps you want to get the totals in 2 stages, like this:
WITH five_column_totals AS
select a, b, c
, fi.x1, fi.x2 -- For debugging only
, SUM (fa.ip1) AS prelim_S1
, SUM (fa.ip2) AS prelim_S2
FROM tab1 FI
, tab2 FA
where fi.x1 = fa.x1
and fi.x2 = fa.x2
group by a, b, c
, f1.x1, f2.x2
SELECT a, b, c
, COUNT (*) AS nrec_of_f1
, SUM (prelim_s1) AS s1
, SUM (prelim_s2) AS s2
FROM five_column_totals
GROUP BY a, b, c
Notice that the sub-query called five_column_totals is essentially what you posted, except that there fi.x1 and fi.x2 are included in the GROUP BY clause. That means the sub-query will hve a separate row for each distinct combination of x1 and x2, which you can COUNT in the main query, GROUPing only BY a, b and c. -
Hi there,
I have a below query that has a count field, which I want to have count of unique records.
SELECT [SGMT_REV_BY_SITE].GLSeq, Count([SGMT_REV_BY_SITE].SITE_ADDR_ID) AS NUM_SITES, [SGMT_REV_BY_SITE].SGMNT1, [SGMT_REV_BY_SITE].SGMNT2, [SGMT_REV_BY_SITE].LOB$, [SGMT_REV_BY_SITE].PERIOD, [SGMT_REV_BY_SITE].RECUR, [SGMT_REV_BY_SITE].PROMOTED, Sum([SGMT_REV_BY_SITE].REV_GRS)
AS REV_GRS_Sum, Sum([SGMT_REV_BY_SITE].REV_NET) AS REV_NET_Sum, IIf(NUM_SITES >0, REV_GRS_Sum/NUM_SITES, REV_GRS_Sum) AS ARPSg_Sum, IIf(NUM_SITES >0,
REV_NET_Sum/NUM_SITES, REV_NET_Sum) AS ARPSn_Sum
FROM SGMT_REV_BY_SITE
WHERE ([SGMT_REV_BY_SITE].SGMNT1="Small"
Or [SGMT_REV_BY_SITE].SGMNT1="Medium")
And [SGMT_REV_BY_SITE].PERIOD>#12/31/2013#
And [SGMT_REV_BY_SITE].RECUR=Yes
And [SGMT_REV_BY_SITE].PROMOTED=Yes
And [SGMT_REV_BY_SITE].REV_NET<>0
GROUP BY [SGMT_REV_BY_SITE].GLSeq, [SGMT_REV_BY_SITE].LOB$, [SGMT_REV_BY_SITE].SGMNT1, [SGMT_REV_BY_SITE].SGMNT2, [SGMT_REV_BY_SITE].PERIOD, [SGMT_REV_BY_SITE].RECUR, [SGMT_REV_BY_SITE].PROMOTED;
Is there an easy way of accomplishing the task.
Thanks in advance for help.ARSagit,
Unfortunatly access don't support count(distinct fieldname) statement...
Workaround is:
SELECT [NS].glseq,
Count([NS].site_addr_id) AS NUM_SITES,
[NS].sgmnt1,
[NS].sgmnt2,
[NS].lob$,
[NS].period,
[NS].recur,
[NS].promoted,
FROM (
SELECT DISTINCT
[sgmt_rev_by_site].glseq,
[sgmt_rev_by_site].site_addr_id
[sgmt_rev_by_site].sgmnt1,
[sgmt_rev_by_site].sgmnt2,
[sgmt_rev_by_site].lob$,
[sgmt_rev_by_site].period,
[sgmt_rev_by_site].recur,
[sgmt_rev_by_site].promoted,
FROM
sgmt_rev_by_site
WHERE [sgmt_rev_by_site].sgmnt1 in ("small","medium")
AND [sgmt_rev_by_site].period >#12/31/2013#
AND [sgmt_rev_by_site].recur = yes
AND [sgmt_rev_by_site].promoted = yes
AND [sgmt_rev_by_site].rev_net <>0) AS NS
GROUP BY [NS].glseq,
[NS].lob$,
[NS].sgmnt1,
[NS].sgmnt2,
[NS].period,
[NS].recur,
[NS].promoted;
With this quer you can join with main query and show num_sites....
Michał -
How i will find out count of record
there is a table emp.it consist two column CODE ,COUNTRY. has value like
1, india
1,china
1,japan
1,koria
2,india
2,china
2, japan
2,viatenam
2,finland
3,india
3,japan
3,china
3,america
3,russia
4, jermany
4,france
i want to see distinct count of record which consist country 'india','china','japan'(a code which has all these 3 values). according to this value output should be 3 (1,2,3)Better suited for PL/SQL forum and here is my attempt at solving this.
SQL> with datatab as (select 1 code, 'india' country from dual
2 union all
3 select 1,'china' from dual
4 union all
5 select 1,'japan' from dual
6 union all
7 select 1,'koria' from dual
8 union all
9 select 2,'india' from dual
10 union all
11 select 2,'china' from dual
12 union all
13 select 2, 'japan' from dual
14 union all
15 select 2,'viatenam' from dual
16 union all
17 select 2,'finland' from dual
18 union all
19 select 3,'india' from dual
20 union all
21 select 3,'japan' from dual
22 union all
23 select 3,'china' from dual
24 union all
25 select 3,'america' from dual
26 union all
27 select 3,'russia' from dual
28 union all
29 select 4, 'jermany' from dual
30 union all
31 select 4, 'france' from dual)
32 select distinct a.code from datatab a
33 where 3 = (select count(code) from datatab b where a.code =b.code and b.country in ('india','china','japan'));
CODE
1
2
3
3 rows selected. -
How to find total count of records in a cursor
Aassume below is the cursor i defined
cursor c1 is select * from emp;
now, i want to find the total count of records in this cursor using an existing function etc., using one line statement.
FYI: c1%rowcount is always giving 0, so i cant rely on this.
Any thoughts, please share.
Thanks in advance.I am just showing this to show how to get the rowcount along with the cursor, if the program has so much gap of between verifying the count(*) and opening the cursor.
Justin actually covered this, he said, oracle has to spend some resources to build this functionality. As it is not most often required, it does not makes much sence to see it as a built-in feature. However, if we must see the rowcount when we open the cursor, here is a way, but it is little bit expensive.
SQL> create table emp_crap as select * from emp where 1 = 2;
Table created.
SQL> declare
2 v_cnt number := 0;
3 zero_rows exception;
4 begin
5 for rec in (select * from (select rownum rn, e.ename from emp_crap e) order by 1 desc)
6 loop
7 if v_cnt = 0 then
8 v_cnt := rec.rn;
9 end if;
10 end loop;
11 if v_cnt = 0 then
12 raise zero_rows;
13 end if;
14 exception
15 when zero_rows then
16 dbms_output.put_line('No rows');
17 end;
18 /
No rows
PL/SQL procedure successfully completed.
-- Now, let us use the table, which has the data
SQL> declare
2 v_cnt number := 0;
3 zero_rows exception;
4 begin
5 for rec in (select * from
6 (select rownum rn, e.ename from emp e)
7 order by 1 desc)
8 loop
9 if v_cnt = 0 then
10 v_cnt := rec.rn;
11 dbms_output.put_line(v_cnt);
12 end if;
13 end loop;
14 if v_cnt = 0 then
15 raise zero_rows;
16 end if;
17 exception
18 when zero_rows then
19 dbms_output.put_line('No rows');
20 end;
21 /
14
PL/SQL procedure successfully completed.Thx,
Sri -
How to display the count distinct in a report
hi,
i have a report with multiple columns in it and with column, say A; i need to display in a calculated column B how many distinct values there are in A across the entire report; how to do that?Hi.
For example:
CALENDAR_YEAR
CALENDAR_MONTH_DESC
count(distinct TIMES.CALENDAR_MONTH_DESC by TIMES.CALENDAR_YEAR)
Count will give you how many distinct months are in year.
Regards
Goran
http://108obiee.blogspot.com -
Performance problem with more than one COUNT(DISTINCT ...) in a query
Hi,
(I hope this is the good forum).
In the following query, I have 2 Count Distinct on 2 different fields of the same table. Execution time is okay (2 s) with one or the other COUNT(DISCTINCT ...) in the SELECT clause, but is not tolerable (12 s) with both together in the query! I have
a similar case with 3 counts: 4 s each, 36 s when together!
I've looked at the execution plan, and it seems that with two count distinct, SQL server sorts the table twice before joining the results.
I do not have much experience with SQL server optimization, and I don't know what to improve and how. The SQL is generated by Business Objects, I have few possibilities to tune it. The most direct way would be to execute 2 different queries, but I'd like
to avoid it.
Any advice?
SELECT
DIM_MOIS.DATE_DEBUT_MOIS,
DIM_MOIS.NUM_ANNEE_MOIS,
DIM_DEMANDE_SCD.CAT_DEMANDE,
DIM_APPLICATION.LIB_APPLICATION,
DIM_DEMANDE_SCD.CAT_DEMANDE ,
count(distinct FAITS_DEMANDE.NB_DEMANDE_FLUX),
count(distinct FAITS_DEMANDE.NB_DEMANDE_RESOL_NIV1)
FROM
ALIM_SID.DIM_MOIS INNER JOIN ALIM_SID.DIM_JOUR ON (DIM_JOUR.SEQ_MOIS=DIM_MOIS.SEQ_MOIS)
INNER JOIN ALIM_SID.FAITS_DEMANDE ON (FAITS_DEMANDE.SEQ_JOUR=DIM_JOUR.SEQ_JOUR)
INNER JOIN ALIM_SID.DIM_APPLICATION ON (FAITS_DEMANDE.SEQ_APPLICATION=DIM_APPLICATION.SEQ_APPLICATION)
INNER JOIN ALIM_SID.DIM_DEMANDE_SCD ON (FAITS_DEMANDE.SEQ_DEMANDE_SCD=DIM_DEMANDE_SCD.SEQ_DEMANDE_SCD)
WHERE
( ( DIM_MOIS.NUM_ANNEE_MOIS ) >201301
GROUP BY
DIM_MOIS.DATE_DEBUT_MOIS,
DIM_MOIS.NUM_ANNEE_MOIS,
DIM_DEMANDE_SCD.CAT_DEMANDE,
DIM_APPLICATION.LIB_APPLICATIONHere is the script, nothing original. Hope this helps.
-- Fact table :
-- foreign keys begin by FK_,
-- measures to counted (COUNT DISTINCT) begin with NB_
CREATE TABLE [ALIM_SID].[FAITS_DEMANDE](
[SEQ_JOUR] [int] NOT NULL,
[SEQ_DEMANDE] [int] NOT NULL,
[SEQ_DEMANDE_SCD] [int] NOT NULL,
[SEQ_APPLICATION] [int] NOT NULL,
[SEQ_INTERVENANT] [int] NOT NULL,
[SEQ_SERVICE_RESPONSABLE] [int] NOT NULL,
[NB_DEMANDE_FLUX] [int] NULL,
[NB_DEMANDE_STOCK] [int] NULL,
[NB_DEMANDE_RESOLUE] [int] NULL,
[NB_DEMANDE_LIVREE] [int] NULL,
[NB_DEMANDE_MEP] [int] NULL,
[NB_DEMANDE_RESOL_NIV1] [int] NULL,
CONSTRAINT [PK_FAITS_DEMANDE] PRIMARY KEY CLUSTERED
[SEQ_JOUR] ASC,
[SEQ_DEMANDE] ASC,
[SEQ_DEMANDE_SCD] ASC,
[SEQ_APPLICATION] ASC,
[SEQ_INTERVENANT] ASC,
[SEQ_SERVICE_RESPONSABLE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [AK_AK_FAITS_DEMANDE_FAITS_DE] UNIQUE NONCLUSTERED
[SEQ_JOUR] ASC,
[SEQ_DEMANDE] ASC,
[SEQ_DEMANDE_SCD] ASC,
[SEQ_APPLICATION] ASC,
[SEQ_INTERVENANT] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] WITH CHECK ADD CONSTRAINT [FK_FAITS_DEMANDE_DIM_APPLICATION] FOREIGN KEY([SEQ_APPLICATION])
REFERENCES [ALIM_SID].[DIM_APPLICATION] ([SEQ_APPLICATION])
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_APPLICATION]
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] WITH CHECK ADD CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE] FOREIGN KEY([SEQ_DEMANDE])
REFERENCES [ALIM_SID].[DIM_DEMANDE] ([SEQ_DEMANDE])
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE]
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] WITH CHECK ADD CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE_SCD] FOREIGN KEY([SEQ_DEMANDE_SCD])
REFERENCES [ALIM_SID].[DIM_DEMANDE_SCD] ([SEQ_DEMANDE_SCD])
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_DEMANDE_SCD]
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] WITH CHECK ADD CONSTRAINT [FK_FAITS_DEMANDE_DIM_INTERVENANT] FOREIGN KEY([SEQ_INTERVENANT])
REFERENCES [ALIM_SID].[DIM_INTERVENANT] ([SEQ_INTERVENANT])
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_INTERVENANT]
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] WITH CHECK ADD CONSTRAINT [FK_FAITS_DEMANDE_DIM_JOUR] FOREIGN KEY([SEQ_JOUR])
REFERENCES [ALIM_SID].[DIM_JOUR] ([SEQ_JOUR])
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_JOUR]
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] WITH CHECK ADD CONSTRAINT [FK_FAITS_DEMANDE_DIM_SERVICE_RESPONSABLE] FOREIGN KEY([SEQ_SERVICE_RESPONSABLE])
REFERENCES [ALIM_SID].[DIM_SERVICE] ([SEQ_SERVICE])
GO
ALTER TABLE [ALIM_SID].[FAITS_DEMANDE] CHECK CONSTRAINT [FK_FAITS_DEMANDE_DIM_SERVICE_RESPONSABLE]
GO
-- not shown : extended properties
-- One of the dimension tables (they all have a primary key named SEQ_)
CREATE TABLE [ALIM_SID].[DIM_JOUR](
[SEQ_JOUR] [int] IDENTITY(1,1) NOT NULL,
[SEQ_ANNEE] [int] NOT NULL,
[SEQ_MOIS] [int] NOT NULL,
[DATE_JOUR] [date] NULL,
[CODE_ANNEE] [varchar](25) NULL,
[CODE_MOIS] [varchar](25) NULL,
[CODE_SEMAINE_ISO] [varchar](25) NULL,
[CODE_JOUR_ANNEE] [varchar](25) NULL,
[CODE_ANNEE_JOUR] [varchar](25) NULL,
[LIB_JOUR] [varchar](25) NULL,
[LIB_JOUR_COURT] [varchar](25) NULL,
[JOUR_OUVRE] [tinyint] NULL,
[JOUR_CHOME] [tinyint] NULL,
CONSTRAINT [PK_DIM_JOUR] PRIMARY KEY CLUSTERED
[SEQ_JOUR] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [ALIM_SID].[DIM_JOUR] WITH CHECK ADD CONSTRAINT [FK_DIM_JOUR_DIM_ANNEE] FOREIGN KEY([SEQ_ANNEE])
REFERENCES [ALIM_SID].[DIM_ANNEE] ([SEQ_ANNEE])
GO
ALTER TABLE [ALIM_SID].[DIM_JOUR] CHECK CONSTRAINT [FK_DIM_JOUR_DIM_ANNEE]
GO
ALTER TABLE [ALIM_SID].[DIM_JOUR] WITH CHECK ADD CONSTRAINT [FK_DIM_JOUR_DIM_MOIS] FOREIGN KEY([SEQ_MOIS])
REFERENCES [ALIM_SID].[DIM_MOIS] ([SEQ_MOIS])
GO
ALTER TABLE [ALIM_SID].[DIM_JOUR] CHECK CONSTRAINT [FK_DIM_JOUR_DIM_MOIS]
GO -
How can I get the number of distinct records that each field of a DB table has?
Hi everyone,
I would like to know how to get he number of distinct records that each field of a DB table has. When tracing a SQL statement either in ST12 or ST05, in the plan execution, if the sentence made useage of an index, then I can click in the index name and see this kind of information (no. of distinct values for each field of that index).
Can I do something like this but with the whole fields of a table?
What I have found until now is in Tx ST10; I search for whatever kind of table statistics and then use the function of "Analyze table" (which takes me to Tx DB05). In here, I can enter a table and up to 5 fields in order to get the information that I want.
Is there any other way to do this?
Regards,
David RezaHi David,
You can export the same to excel and sort as per requirement.
Sorry is that what you are looking for ?
Regards,
Deepanshu Sharma -
How to know the count of record in CR XI?
Post Author: Liu ming
CA Forum: Deployment
Hi All,
I create a report by CR XI release 2. The report is viewed in ASP.Net. So, I would like show a message when the report have no record. My question is how to know the count of record?
Thanks.I was able to do this by using
ora:countNodes('Receive_1_Read_InputVariable','BILL','/ns2:BILL/ns2:CMS1500') -
Need a relative sequence (count of record) in an input file in ESB input fi
I am using ESB to pick up text files and pass them to a stored procedure. I have multiple variable length records in the file. I pass each record to the
output file adapter, along with the input filename. I would also like to get a relative record number for each record within the file. I use an xsd file
to convert the input to XML. The entire file is at the root level, each record is an element. Is there a way to get a relative count of each element?
Here is the xsd file:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
targetNamespace="http://TargetNamespace.com/Filein"
xmlns:tns="http://TargetNamespace.com/Filein"
elementFormDefault="qualified"
attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
<xsd:element name="Root-Element">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C1" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="C1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy=""">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<!--NXSDWIZ:J:\\UPLD5383.INM:-->
<!--USE-HEADER:false:-->
I need to map the relative record number to a field in the output.
Is there a function similar to the get filename that would return this value to me?
<xsl:value-of select='ehdr:getRequestHeader("/fhdr:InboundFileHeaderType/fhdr:fileName","fhdr=http://xmlns.oracle.com/pcbpel/adapter/file/;")'/>
I use this in the xsl file to get the file name .does each record start with a new line? if it does a
simple wc -l can help you. If not, you can pre
process this XML file by first removing all the new
line characters using sed and then adding new line
characters after the end tag of the xml using sed and
finally doing a wc -l . this would be a simple shell
script. Not sure if you want to use Unix shell
scripting to achieve this.The sheer nature of XML means that it does not conform to any visual formatting. i.e. An xml file containing...
<employee><empno>3</empno></employee>
is identical in XML terms to...
<employee>
<empno>3</empno>
</employee>
which is also identical in XML terms to...
<employee>
<empno>
3
</empno>
</employee>
which is also identical in XML terms to...
<employee><empno>
3
</empno></employee>
etc.
You cannot rely on the number of CR's or CR/LF's in the file to count the records. Proper XML processing should be used for such a task.
Maybe you are looking for
-
Edit Bex Query in SAP Gui?
Hi, Anyone know if it is possible to edit a Bex Query in the SAP Gui? For instance with a T-code or Program in SE38? Having problem with my Bex fontend and am not allowed to install patches on this computer. Only need to remove on Free charracteristi
-
Location of printing templates
I just moved to a new PC with better performance. I copied all LR files under User(I think) but I lost all my printing templates. How can I restore my printing templates? I am running Vista Ultimate. Lennart
-
TA38263 there is no burn tab in preferences
I have called up preferences but there is no burn tab. How doI fix this
-
I'm on a Mac OS X 10.6.8 and all of a sudden one day my iTunes failed to launch. The problem has persisted for months now--I've tried reinstalling, updating all software, removing all music files (which I backed up), I tried Safe Launching it--NOTHIN
-
In GRC CUP for UAR,Reason for Rejection
Hi, What is the standard reason for rejection Reason code and description. Thanks Mash