IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage SQL Discussion :

requete SQL intersect/not exist


Sujet :

Langage SQL

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    132
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 132
    Points : 69
    Points
    69
    Par défaut requete SQL intersect/not exist
    bonjour, voici ma requête

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
     
       select
          pid_log, 
          jobname_log,
          dbtimestamp_log, 
          dbendstamp_log, 
          timediff(`dbendstamp_log`,`dbtimestamp_log`) AS Duree, 
          script_log, 
          args_log, 
          returncode_log
        from 
        log
        where true  
        AND message_log!='Wrapper End'
        AND dbtimestamp_log between '".$date2."' and  '".$date1."'
        UNION
        select
          pid_log, 
          jobname_log,
          dbtimestamp_log, 
          dbendstamp_log, 
          timediff(`dbendstamp_log`,`dbtimestamp_log`) AS Duree, 
          script_log, 
          args_log, 
          returncode_log
        from 
        log
        where true  
        AND message_log!='Wrapper End'
        AND dbtimestamp_log between '".$date3."' and  '".$date4."'
        order by dbtimestamp_log DESC,  returncode_log DESC
        ;
    j'aimerai savoir comment la modifier afin que celle ci me donne au résultat seulement les lignes qui n'existent que pour les dates3/4 et ou dates1/2

    pour résumer je veux le nom des jobs et des scripts qui ont tourné durant la première et qui n'ont pas tourné dans la 2e ou
    qui on tourné dans la 2e nuit et pas la première

    d'avance merci

  2. #2
    Rédacteur

    Avatar de SQLpro
    Homme Profil pro
    Expert bases de données / SQL / MS SQL Server / Postgresql
    Inscrit en
    Mai 2002
    Messages
    21 772
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Expert bases de données / SQL / MS SQL Server / Postgresql
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2002
    Messages : 21 772
    Points : 52 732
    Points
    52 732
    Billets dans le blog
    5
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    select pid_log, jobname_log, dbtimestamp_log, dbendstamp_log, 
           timediff('dbendstamp_log','dbtimestamp_log') AS Duree, 
           script_log, args_log, returncode_log
    from   log
    where  message_log <> 'Wrapper End'
      AND  dbtimestamp_log between CAST('".$date2."' AS DATE) 
                               and CAST('".$date1."' AS DATE)
    UNION  ALL
    select pid_log, jobname_log, dbtimestamp_log, dbendstamp_log, 
           timediff('dbendstamp_log','dbtimestamp_log') AS Duree, 
           script_log, args_log, returncode_log
    from   log
    where  message_log <> 'Wrapper End'
      AND  dbtimestamp_log between CAST('".$date3."' AS DATE) 
                               and  CAST('".$date4."' AS DATE) 
    ORDER  BY dbtimestamp_log DESC, returncode_log DESC
    Sans la définition de vos tables et la sémantique associée, impossible de vous aider !

    A +
    Frédéric Brouard - SQLpro - ARCHITECTE DE DONNÉES - expert SGBDR et langage SQL
    Le site sur les SGBD relationnels et le langage SQL: http://sqlpro.developpez.com/
    Blog SQL, SQL Server, SGBDR : http://blog.developpez.com/sqlpro
    Expert Microsoft SQL Server - M.V.P. (Most valuable Professional) MS Corp.
    Entreprise SQL SPOT : modélisation, conseils, audit, optimisation, formation...
    * * * * * Expertise SQL Server : http://mssqlserver.fr/ * * * * *

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    132
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 132
    Points : 69
    Points
    69
    Par défaut infos manquante pour la requête
    Merci de me préciser qu'il manquait des informations :p

    détail de la table

    Table Name: log
    column Name Datatype
    id_log Integer
    dbtimestamp_log Timestamp
    timestamp_log Datetime
    dbendstamp_log Timestamp
    endstamp_log Datetime
    returncode_log Integer
    script_log varchar(200)
    pid_log varchar(30)
    jobname_log varchar(45)
    définition des variables
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    $date1=date("Y-m-d 08:00:00");
    $date2=date("Y-m-d 19:00:00", time()-3600*24);
    $date3=date("Y-m-d 08:00:00", time()-3600*24);
    $date4=date("Y-m-d 19:00:00", time()-3600*48);
    requête SQL
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
        select
          pid_log, 
          jobname_log,
          dbtimestamp_log, 
          dbendstamp_log, 
          timediff(`dbendstamp_log`,`dbtimestamp_log`) AS Duree, 
          script_log, 
          args_log, 
          returncode_log
        from 
        log
        where true  
        AND message_log!='Wrapper End'
        AND dbtimestamp_log between '".$date2."' and  '".$date1."'
        UNION
        select
          pid_log, 
          jobname_log,
          dbtimestamp_log, 
          dbendstamp_log, 
          timediff(`dbendstamp_log`,`dbtimestamp_log`) AS Duree, 
          script_log, 
          args_log, 
          returncode_log
        from 
        log
        where true  
        AND message_log!='Wrapper End'
        AND dbtimestamp_log between '".$date3."' and  '".$date4."'
        order by dbtimestamp_log DESC,  returncode_log DESC
    j'espère que cela peut vous aider plus

    d'avance merci

Discussions similaires

  1. [MySQL-5.5] Requete INSERT if not exists
    Par Motti2 dans le forum Requêtes
    Réponses: 2
    Dernier message: 27/05/2013, 10h49
  2. requete sql avec not in
    Par diengkals dans le forum Requêtes
    Réponses: 3
    Dernier message: 27/01/2013, 16h06
  3. REQUETE INSERT WHERE NOT EXISTS
    Par tidou95220 dans le forum Langage SQL
    Réponses: 1
    Dernier message: 27/03/2012, 13h35
  4. Réponses: 7
    Dernier message: 18/07/2008, 09h44
  5. PROBLEME AVEC LES REQUETES IS NULL / NOT EXISTS
    Par sylvaine dans le forum Langage SQL
    Réponses: 5
    Dernier message: 04/06/2004, 13h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo