2010-02-17 52 views
0
SELECT A.ID_ListGroupParIzm, A.Name, 0 AS Point 
FROM CfgListGroupParIzm A, CfgIzmeritel B 
WHERE A.ID_TypeIzmerit = B.ID_TypeIzmerit 
AND [email protected]_Izmerit AND A.ForRun=0 

UNION 

SELECT A.ID_ListGroupParIzm, (C.Name + ' ' + A.Name) AS Name, C.ID_IzmerPoint AS Point 
FROM CfgListGroupParIzm A, CfgIzmeritel B, CfgIzmerPoint C 
WHERE A.ID_TypeIzmerit = B.ID_TypeIzmerit 
AND [email protected]_Izmerit AND A.ForRun=1 
AND [email protected]_Izmerit 

EXCEPT 

SELECT ID_Group --, '' AS Name, 0 AS Point here I don't know their names and a Point :(
FROM TbUserGroup 
WHERE [email protected]_Izmerit AND 
[email protected]_User AND [email protected]_Point 

有想法 - 用除,但我需要知道它的所有字段(只有一個我知道的),所以我需要從ID_Group除非在這個聯盟節點排除: - /我在想結合它。從工會排除只有一個場

如何製作它?或者一些想法......或建議......

回答

2

你可以嘗試像

SELECT * 
FROM (
      SELECT A.ID_ListGroupParIzm, 
        A.Name, 
        0 AS Point 
      FROM CfgListGroupParIzm A, 
        CfgIzmeritel B 
      WHERE A.ID_TypeIzmerit = B.ID_TypeIzmerit  
      AND  [email protected]_Izmerit 
      AND  A.ForRun=0 
      UNION 
      SELECT A.ID_ListGroupParIzm, 
        (C.Name + ' ' + A.Name) AS Name, 
        C.ID_IzmerPoint AS Point 
      FROM CfgListGroupParIzm A, 
        CfgIzmeritel B, 
        CfgIzmerPoint C 
      WHERE A.ID_TypeIzmerit = B.ID_TypeIzmerit 
      AND  [email protected]_Izmerit 
      AND  A.ForRun=1 
      AND  [email protected]_Izmerit 
     ) sub 
WHERE sub.ID_ListGroupParIzm NOT IN 
       (
        SELECT ID_Group 
        FROM TbUserGroup 
        WHERE [email protected]_Izmerit 
        AND  [email protected]_User 
        AND  [email protected]_Point 
       ) 
+0

是的,它的工作原理,再次感謝你 – Cynede 2010-02-17 06:01:16