1

我很接近,现在我只是遇到了这段代码的问题。它说我需要在某处添加存在?谢谢您的帮助!

SELECT (SELECT UA#SacmiDataLog_2013.NS_Inlet_T
                  , UA#SacmiDataLog_2013.NSFlowRate
                  , UA#SacmiDataLog_2013.NSHeaterTank
                  , UA#SacmiDataLog_2013.NS_Outlet_T
                  , UA#SacmiDataLog_2013.NSTrPrAvg
                  , UA#SacmiDataLog_2013.NSPump1
                  , UA#SacmiDataLog_2013.NSPump2
                  , UA#SacmiDataLog_2013.NS_Visc
                  , UA#SacmiDataLog_2013.NS_Burner_B
             WHERE
               UA#SacmiDataLog_2013.NSHeatBatch = 'G23169') AS expr1
          , (SELECT UA#SacmiDataLog_2013.OS_Inlet_T
                  , UA#SacmiDataLog_2013.OS_Outlet_T
                  , UA#SacmiDataLog_2013.OS_Burner_B
                  , UA#SacmiDataLog_2013.OSViscosity
                  , UA#SacmiDataLog_2013.OSHeaterTank
                  , UA#SacmiDataLog_2013.OSPump1
                  , UA#SacmiDataLog_2013.OSPump2
                  , UA#SacmiDataLog_2013.OSTrPrAvg
             WHERE
               UA#SacmiDataLog_2013.OSHeatBatch = 'G23169') AS expr2

FROM dbo.UA#SacmiDataLog_2013

4

2 回答 2

0

你试过这样吗:

where (NSHeatBatch= 'G22166' or OSHeatBatch= 'G22166') 
and RunDate between '1/14/13' and '1/16/13'

很多时候,您的大括号对于定义查询非常重要。让我们试试吧……!

于 2013-06-14T11:06:50.930 回答
0

然后,这样做,我希望这会有所帮助:

SELECT  * FROM( 
    SELECT NSField1 as DataColumnNameSame1,NSField2 as DataColumnNameSame2 FROM SAMETABLE AS NS WHERE NS.BATCH='111111' AND RUNDATE BETWEEN '1/14/13' AND '1/16/13' 

UNION ALL

    SELECT OSField1 as DataColumnNameSame1,OSField2 as DataColumnNameSame2 FROM SAMETABLE AS NS WHERE OS.BATCH='111111' AND RUNDATE BETWEEN '1/14/13' AND '1/16/13' 

) AS DATA 
    --WHERE CRITERIA IF NECESSARY IN THIS LEVEL TOO, ONCE AGAIN YOU CAN FILTER FROM HERE ALSO IF NEEDED. HOPE THIS HELPS.
于 2013-06-14T16:21:15.597 回答