Advertisement

08.20.2007 at 10:12PM PDT, ID: 22775915
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

SQL Joining Views ?

Asked by vitoto in Oracle Database

Tags: , ,

Hi, i have this SQL :

Select to_char(sysdate, 'yyyymmdd') as fec, afi_inscritos.no_afiliacion || '-' || afi_inscritos.correlativo as cod_beneficiario, afi_inscritos.no_afiliacion,
afi_inscritos.tipo_parentesco, afi_inscritos.sexo, to_char(afi_inscritos.fecha_nacimiento, 'yyyymmdd') as fecha_nac,
to_char(afi_inscritos.afi_fecha_inscripcion, 'yyyymmdd') as fecha_insc,
'',
afi_asegurados.cod_unidad_medica || afi_asegurados.cod_clinica as centro_medico,
afi_inscritos.status_benefi, afi_asegurados.afi_status_asegurado,
afi_inscritos.status_registro, afi_inscritos.depto_direcc || afi_inscritos.munic_direcc as depto_muni_resid, RTRIM(afi_inscritos.cod_usuario) as u_systema,
afi_inscritos.estado_civil, 'X'
from afi_inscritos, afi_asegurados
WHERE ((afi_inscritos.no_afiliacion = afi_asegurados.no_afiliacion)
AND (afi_inscritos.status_benefi = '1')
AND (afi_inscritos.tipo_parentesco <> '3')
AND (afi_inscritos.tipo_parentesco <> '5'))
group by afi_inscritos.no_afiliacion, afi_inscritos.correlativo, afi_inscritos.tipo_parentesco,
afi_inscritos.sexo, afi_inscritos.fecha_nacimiento,
afi_inscritos.afi_fecha_inscripcion, afi_asegurados.cod_unidad_medica,
afi_asegurados.cod_clinica, afi_inscritos.status_benefi, afi_asegurados.afi_status_asegurado,
afi_inscritos.status_registro, afi_inscritos.depto_direcc, afi_inscritos.munic_direcc, afi_inscritos.cod_usuario, afi_inscritos.estado_civil

For this SQL we too have VIew : BENEFI_TD

I need ADD Field : to_char(max(pfd_fechas.fechcert), 'yyyymmdd') as fecvenc
From this SQL :

SELECT my_table.*,
DECODE(DENSE_RANK() OVER (PARTITION BY no_afiliacion ORDER BY numpat),1,'X',' ') as flag
FROM
(SELECT to_char(sysdate, 'yyyymmdd') as fec, afi_asegurados.no_afiliacion as no_afiliacion,
afi_asegurados.sexo, pfd_detalle.numpat as numpat,
afi_asegurados.cod_unidad_medica || afi_asegurados.cod_clinica as centro_medico,
afi_asegurados.afi_status_asegurado, to_char(max(pfd_fechas.fechcert), 'yyyymmdd') as fecvenc, to_char(fecha_nacimiento, 'yyyymmdd') as fecha_naci,
to_char(fecha_inscripcion, 'yyyymmdd') as fecha_insc, afi_asegurados.status_registro, afi_asegurados.estado_civil,
afi_asegurados.depto_direcc || afi_asegurados.munic_direcc as depto_muni_resi, to_char(afi_asegurados.fecha_muerte, 'yyyymmdd') as fecha_muerte, RTRIM(afi_asegurados.cod_usuario) as u_systema,
to_char(afi_asegurados.afi_ult_fecha_incap_inic, 'yyyymmdd') as fecha_ulicap, to_char(rtrim(afi_asegurados.nit)) as nit, to_char(rtrim(afi_asegurados.dui)) as dui,
RTRIM(REPLACE(afi_asegurados.afi_ultimo_salario,',','.')) as ult_salar
FROM sgcuser.pfd_detalle, sgcuser.afi_asegurados, sgcuser.pat_patronos, sgcuser.pfd_fechas
WHERE ( (pat_patronos.no_patronal = afi_asegurados.no_patronal)
AND (afi_asegurados.no_afiliacion = pfd_detalle.numafil)
AND (pfd_detalle.periodo = pfd_fechas.periodo)
AND (to_char(pfd_fechas.fechcert, 'yyyymm') >= to_char(sysdate, 'yyyymm'))
AND (afi_asegurados.no_afiliacion <> '000000000'))
Group by afi_asegurados.no_afiliacion,
afi_asegurados.sexo, pfd_detalle.numpat,
afi_asegurados.cod_unidad_medica, afi_asegurados.cod_clinica,
afi_asegurados.afi_status_asegurado, afi_asegurados.fecha_nacimiento,
afi_asegurados.fecha_inscripcion, afi_asegurados.status_registro,
afi_asegurados.estado_civil, afi_asegurados.depto_direcc, afi_asegurados.munic_direcc,
afi_asegurados.fecha_muerte, afi_asegurados.cod_usuario,
afi_asegurados.afi_ult_fecha_incap_inic,afi_asegurados.nit, afi_asegurados.dui,afi_asegurados.afi_ultimo_salario) my_table;

For this SQL we too have VIew : AFIS_TD

I not can fix using unique SQL, ROWs is LESS.

Is posible make some View using SELECT * FROM BENEFI_TD getting Field  to_char(max(pfd_fechas.fechcert), 'yyyymmdd') as fecvenc from view AFIS_TD

Key Fields is afi_asegurados.no_afiliacion in view AFIS_TD and Key afi_asegurados.no_afiliacion and afi_inscritos.no_afiliacion || '-' || afi_inscritos.correlativo as cod_beneficiario from view BENEFI_TD

Any idea, we only can extract from Views or Tables when using JDBC Drivers in SAP.

Thank you.



Start Free Trial
[+][-]08.20.2007 at 11:23PM PDT, ID: 19735819

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.21.2007 at 05:08AM PDT, ID: 19737018

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.21.2007 at 04:22PM PDT, ID: 19742515

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.22.2007 at 01:36AM PDT, ID: 19744403

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: views, joining, to_char
Sign Up Now!
Solution Provided By: jinesh_kamdar
Participating Experts: 2
Solution Grade: B
 
 
[+][-]10.19.2007 at 09:09PM PDT, ID: 20113704

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628