PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > with Query
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
with Query

Réponse
 
LinkBack Outils de la discussion
Vieux 10/09/2008, 01h24   #1
SirCodesALot
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut with Query

Hi All,

I am hoping some of your talented minds can me with a query. I
have two tables that look like this.

Table1

UID--NAME--PROGRAM--COMPANY

Table2

UID--STATUS--ISMGR

I want to get all the Unique PROGRAM names that have a particular
STATUS is there way to do this? I UID in Table1 may or may not exist
in Table2.

like

select distinct t1.program from Table1 as t1 JOIN on Table2 as t2
with where STATUS ='X' and t1.uid = t2.uid

Anyone have a clue?

Thanks,
-SJ
  Réponse avec citation
Vieux 10/09/2008, 01h34   #2
Russell Fields
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: with Query

SJ,

SELECT A.UID, A.PROGRAM, B.STATUS
FROM Table1 A JOIN Table2 B
ON A.UID = B.UID
WHERE B.STATUS = SomeValue
GROUP BY A.UID, A.PROGRAM, B.STATUS

The GROUP BY is in case there are multiple Table2 rows with the same status
for the same ID. Et cetera. (Logically, there should not be, but I don't
know your constraints.)

RLF

"SirCodesALot" <sjourdan@gmail.com> wrote in message
news:3c803eba-8fbf-4a21-8883-44fd7c51ac99@r66g2000hsg.googlegroups.com...
> Hi All,
>
> I am hoping some of your talented minds can me with a query. I
> have two tables that look like this.
>
> Table1
>
> UID--NAME--PROGRAM--COMPANY
>
> Table2
>
> UID--STATUS--ISMGR
>
> I want to get all the Unique PROGRAM names that have a particular
> STATUS is there way to do this? I UID in Table1 may or may not exist
> in Table2.
>
> like
>
> select distinct t1.program from Table1 as t1 JOIN on Table2 as t2
> with where STATUS ='X' and t1.uid = t2.uid
>
> Anyone have a clue?
>
> Thanks,
> -SJ



  Réponse avec citation
Vieux 10/09/2008, 01h38   #3
Roy Harvey (SQL Server MVP)
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: with Query

On Tue, 9 Sep 2008 16:24:54 -0700 (PDT), SirCodesALot
<sjourdan@gmail.com> wrote:

>I want to get all the Unique PROGRAM names that have a particular
>STATUS is there way to do this? I UID in Table1 may or may not exist
>in Table2.
>
>like
>
>select distinct t1.program from Table1 as t1 JOIN on Table2 as t2
>with where STATUS ='X' and t1.uid = t2.uid


SELECT distinct
t1.program
FROM Table1 as t1
LEFT OUTER
JOIN Table2 as t2
ON t1.STATUS = 'X'
AND t1.uid = t2.uid

Roy Harvey
Beacon Falls, CT
  Réponse avec citation
Vieux 10/09/2008, 01h42   #4
SirCodesALot
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: with Query

On Sep 9, 6:34pm, "Russell Fields" <russellfie...@nomail.com> wrote:
> SJ,
>
> SELECT A.UID, A.PROGRAM, B.STATUS
> FROM Table1 A JOIN Table2 B
> ON A.UID = B.UID
> WHERE B.STATUS = SomeValue
> GROUP BY A.UID, A.PROGRAM, B.STATUS
>
> The GROUP BY is in case there are multiple Table2 rows with the same status
> for the same ID. Et cetera. (Logically, there should not be, but I don't
> know your constraints.)
>
> RLF
>
> "SirCodesALot" <sjour...@gmail.com> wrote in message
>
> news:3c803eba-8fbf-4a21-8883-44fd7c51ac99@r66g2000hsg.googlegroups.com...
>
>
>
> > Hi All,

>
> > I am hoping some of your talented minds can me with a query. I
> > have two tables that look like this.

>
> > Table1

>
> > UID--NAME--PROGRAM--COMPANY

>
> > Table2

>
> > UID--STATUS--ISMGR

>
> > I want to get all the Unique PROGRAM names that have a particular
> > STATUS is there way to do this? I UID in Table1 may or may not exist
> > in Table2.

>
> > like

>
> > select distinct t1.program from Table1 as t1 JOIN on Table2 as t2
> > with where STATUS ='X' and t1.uid = t2.uid

>
> > Anyone have a clue?

>
> > Thanks,
> > -SJ- Hide quoted text -

>
> - Show quoted text -


Thanks alot! Wow that was fast. I really appreciate it.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h08.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11048 seconds with 12 queries