Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Sql query

Author  Topic 

vijayanto
Starting Member

16 Posts

Posted - 2009-06-18 : 00:43:57
hi friends,
i have trouble to make a query
so that the query is,

SELECT T0.Custcode, T0.WINo, T0.DateofCalib, T0.CustomerRef, T0.OurRef, T0.CalibOnReceipt, T0.NextCalibDate, T0.UUTName, T0.Make, T0.Model, T0.IDRef,T0.Description, T0.CalibCertNo,T0.MasterCalibdate, T0.MasterNextCalibdate, T0.CalibAgency, T0.Temperature, T0.Humidity, T0.Calibby,T0.CalibCertNumber,T0.CalibratedDate,T0.NextCalibrationDate, T0.CustName, T0.UniqueID, T1.UniqueID AS Expr1,T1.Range,T1.resultrecord,T1.Paraname, T1.Trueval, T1.UOM, T1.R1, T1.R2, T1.R3, T1.rAverage, T1.rstdev, T1.typeA, T1.calistab, T1.typeB1, T1.calibunc, T1.typeB2,T1.UUTResB3, T1.CoilUnc, T1.CombinedUnc, T1.DOF, T1.KFactor, T1.ExpUnc, T1.EUncPerc, T1.Resolution, T1.ErrorClaimed, T1.ErrorObserved, T2.Address, T2.Code FROM Dataobserb AS T0 LEFT OUTER JOIN
Parameterdup AS T1 ON T0.UniqueID = T1.UniqueID LEFT OUTER JOIN
Customer AS T2 ON T2.Code = T0.Custcode

so here if the field T1.ExpUnc is null then the T1.Range and the T1.Trueval should not display in the query

Regards
vijay

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-18 : 00:57:04
CASE WHEN t1.expunc is null then null else t1.range end as range,
CASE WHEN t1.expunc is null then null else t1.trueval end as trueval



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

vijayanto
Starting Member

16 Posts

Posted - 2009-06-18 : 01:02:04
quote:
Originally posted by Peso

CASE WHEN t1.expunc is null then null else t1.range end as range,
CASE WHEN t1.expunc is null then null else t1.trueval end as trueval



E 12°55'05.63"
N 56°04'39.26"



hi buddy,
in sql server the case statement is supported and it shows error as incorrect syntax
Go to Top of Page

vijayanto
Starting Member

16 Posts

Posted - 2009-06-18 : 01:03:48
hi buddy,
in sql server the case statement is supported and it shows error as incorrect syntax

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-18 : 01:08:48
There is no error when properly implemented.

SELECT T0.Custcode, T0.WINo, T0.DateofCalib, T0.CustomerRef, T0.OurRef, T0.CalibOnReceipt, T0.NextCalibDate, T0.UUTName, T0.Make, T0.Model, T0.IDRef,T0.Description, T0.CalibCertNo,T0.MasterCalibdate, T0.MasterNextCalibdate, T0.CalibAgency, T0.Temperature, T0.Humidity, T0.Calibby,T0.CalibCertNumber,T0.CalibratedDate,T0.NextCalibrationDate, T0.CustName, T0.UniqueID, T1.UniqueID AS Expr1,
CASE WHEN t1.expunc is null then null else t1.range end as range,
T1.resultrecord,T1.Paraname,
CASE WHEN t1.expunc is null then null else t1.trueval end as trueval,
T1.UOM, T1.R1, T1.R2, T1.R3, T1.rAverage, T1.rstdev, T1.typeA, T1.calistab, T1.typeB1, T1.calibunc, T1.typeB2,T1.UUTResB3, T1.CoilUnc, T1.CombinedUnc, T1.DOF, T1.KFactor, T1.ExpUnc, T1.EUncPerc, T1.Resolution, T1.ErrorClaimed, T1.ErrorObserved, T2.Address, T2.Code FROM Dataobserb AS T0 LEFT OUTER JOIN
Parameterdup AS T1 ON T0.UniqueID = T1.UniqueID LEFT OUTER JOIN
Customer AS T2 ON T2.Code = T0.Custcode


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

vijayanto
Starting Member

16 Posts

Posted - 2009-06-18 : 03:04:43
Thanks ya
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-18 : 03:48:55
You're welcome.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -