Précédent   Forum des professionnels en informatique > Bases de données > Décisions SGBD
Décisions SGBD Forum de décisions sur le choix en bases de données. Le Comparatif
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 26/05/2005, 17h11   #1
Invité de passage
 
Inscription : juillet 2002
Messages : 7
Détails du profil
Informations forums :
Inscription : juillet 2002
Messages : 7
Points : 0
Points : 0
Par défaut Union de requetes sql

Bonjour à tous,

j'ai un problème au niveau de SQL, je veux regrouper qlq requetes entre eux pour avoir une seule requete (je fais Union) mais le résultat que je trouve n'est pas juste...

1 ere requete:

select f1.id,
f1.longname,( select s1.value
from code s1
join codeinternal s2
on s1.codeinternal_id = s2.id
where s2.refobjectid = f1.id
and s1.system_id = 1
and s2.refobjecttype = 'Instrument'
) ISIN,( select longname
from cst_instrument_type
where id = f1.type
) Type,( select subtype_longname
from instrument_type
where subtype_id = f1.subtype
and rownum = 1
) SubType

from instrument f1
where not exists(
select 1
from price w1
where w1.instrument_id = f1.id
)

and f1.type in (2, 3, 4, 6, 8, 9)
and f1.enabled = '1'

order by Type, Subtype, f1.longname


********************************************


2 eme requete:

select f1.id,
f1.longname,
(
select s1.value
from code s1
join codeinternal s2
on s1.codeinternal_id = s2.id
where s2.refobjectid = f1.id
and s1.system_id = 1
and s2.refobjecttype = 'Instrument'
) ISIN,
(select longname from cst_instrument_type where id = f1.type) Type,
(select subtype_longname from instrument_type where subtype_id = f1.subtype and rownum = 1) SubType
from instrument f1
where exists (
select 1
from price w1
where w1.instrument_id = f1.id
and w1.objecttype_id = 'RT'
)
and not exists (
select 1
from price w1
where w1.instrument_id = f1.id
and w1.objecttype_id = 'HS'
)
and f1.type in (2, 3, 4, 6, 8, 9)
and f1.enabled = '1'
order by Type, Subtype, f1.longname
bejaad est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/05/2005, 17h42   #2
Rédacteur/Modérateur

 
Avatar de SQLpro
 
Homme Frédéric BROUARD
Expert SGBDR & SQL
Inscription : mai 2002
Messages : 10 959
Détails du profil
Informations personnelles :
Nom : Homme Frédéric BROUARD
Localisation : France

Informations professionnelles :
Activité : Expert SGBDR & SQL
Secteur : Conseil

Informations forums :
Inscription : mai 2002
Messages : 10 959
Points : 17 793
Points : 17 793
Quel est le problème ? message d'erreur ???
Soit plus explicite !

Respecte ceci : http://www.developpez.net/forums/viewtopic.php?t=32668

Poste tes requête en code en utilisant les balises.

A +
__________________
Frédéric Brouard - SQLpro - ARCHITECTE DE DONNÉES - expert SGBDR et langage SQL
Site sur les SGBD relationnels et le langage SQL: http://sqlpro.developpez.com/
Expert Microsoft SQL Server - M.V.P. (Most valuable Professional) MS Corp.
Blog SQL, SQL Server, modélisation données : http://blog.developpez.com/sqlpro
http://www.sqlspot.com : modélisation, conseils, audit, optimisation, formation
* * * * * Enseignant CNAM PACA - ISEN Toulon - CESI Aix en Provence * * * * *
SQLpro est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h21.


 
 
 
 
Partenaires

Hébergement Web