Вы находитесь на странице: 1из 2

SELECT cust_no, COUNT(*) AS "Count of Policy" FROM POLICY_ENTITY GROUP BY cust_n

o ;
SELECT cust_no, COUNT(*) AS "Count of Policy" FROM customer GROUP BY cust_no;
select * from PROD_LINE_DISC;
select DISTINCT prod_id from POLICY_ENTITY;
select * from POLICY_ENTITY;
select * from customer;
select count (DISTINCT cust_no ) from customer;
select count (*) from (select POLICY_ENTITY.policy_no ,POLICY_ENTITY.prod_id , c
ustomer.cust_no from customer INNER JOIN POLICY_ENTITY ON POLICY_ENTITY.cust_no
= customer.cust_no);
select count (*) from (select name.surname ,name.id_no , customer.cust_no from n
ame INNER JOIN customer ON name.id_no = customer.cust_no);
select name.surname ,name.id_no , customer.cust_no from name INNER JOIN customer
ON name.id_no = customer.cust_no;
SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'NAME';
SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'CUSTOMER';
SELECT * FROM ALL_CONS_COLUMNS WHERE TABLE_NAME = 'NAME';
select * from name where EFFECTIVE_DATE is not null;
select count (distinct OCCUPATION) from customer;
select * from customer where birth_date is null;
SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'NAME';
SELECT * FROM ALL_CONS_COLUMNS WHERE TABLE_NAME = 'NAME';
select count (NO_MARKETING_IND) from customer;
select count (VIP_STATUS) from customer;
select count (DISTINCT potential) from customer;
SELECT * FROM ALL_CONS_COLUMNS WHERE TABLE_NAME = 'CUSTOMER';
SELECT table_name, column_name, data_type, data_length FROM USER_TAB_COLUMNS WHE
RE table_name = 'CUSTOMER_AUDIT';
SELECT forename ,COUNT(*) count FROM name GROUP BY forename Having COUNT(*) > 10
0;
SELECT segment_name,segment_type,bytes/1024/1024/1024 gb FROM dba_segments
WHERE segment_type='TABLE' AND segment_name in('CUSTOMER','NAME','POLICY_ENTITY'
);
SELECT segment_name table_name, sum(bytes)/(1024*1024*1024) table_size_in_gb FRO
M user_extents
WHERE segment_type='TABLE' AND segment_name in ('CUSTOMER','NAME','POLICY_ENTITY
','POLICY') GROUP BY segment_name;
select * from name where surname is not null and forename is null;
select count (*) from customer where birth_date is null;
select count (*) from (select cust_no from customer minus select id_no from name
);
select count (*) from (select id_no from name minus select cust_no from custome
r);
select * from name where id_no in (select id_no from name minus select cust_no
from customer);
Summary
select * from POLICY_ENTITY;
select prod_id,current_policy_status,count(*) from policy_entity group by prod_i
d,current_policy_status order by prod_id,current_policy_status;
select prod_id,count(*) from policy_entity group by prod_id order by prod_id;
select current_policy_status,count(*) from policy_entity group by current_policy
_status order by current_policy_status;
select prod_id,count(DISTINCT cust_no) from policy_entity group by prod_id orde
r by prod_id;
To see the duplicate records, follow the example below:

SELECT * FROM TABLE_B WHERE (COLUMN_A||COLUMN_B) IN (SELECT COLUMN_A||COLUMN_B F


ROM TABLE_A);
SELECT COUNT(*), COLUMN_A, COLUMN_B FROM TABLE_B GROUP BY COLUMN_A, COLUMN_B HAV
ING COUNT(*)>1;
select column_name, count(column_name) from table group by column_name having co
unt (column_name) > 1;
SELECT * FROM TABLE A WHERE EXISTS (SELECT 1 FROM TABLE WHERE COLUMN_NAME = A.CO
LUMN_NAME AND ROWID < A.ROWID)

Вам также может понравиться