Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IIF(,,) in an SQL Server SQL Statement
Message
 
 
À
18/04/2000 14:05:27
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00360347
Message ID:
00361042
Vues:
23
Without a GROUP BY clause, you can't have a HAVING clause. You could try adding the Timeitms.timeout constraint to the WHERE clause but this will still give you mulitple instances of Timehd.empid if there are multiple values >17.

>>I can't find the HAVING clause in the SELECT from SQL Server... Could that be it?
>

>Yes, But it doesn't work the same as fox I always get the following "Type" of error.:
>
>Server: Msg 8118, Level 16, State 1, Line 4
>Column 'timehd.empid' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
>
>
>I understand why I'm getting some of them. So I'll refine my statement to something like... Um, thanks for forcing me to think Sylvain. The following Statement seems to do it:
>
>DECLARE @dNextChkDate DATETIME
>SET @dNextChkDate = CONVERT(DATETIME, '04/21/2000',101)-(14*1)
>
>SELECT Timehd.empid, Timehd.date,
>CASE
>WHEN Timeitms.timeout>17 AND Timeitms.timein>17 THEN Timeitms.timeout-Timeitms.timein
>ELSE Timeitms.timeout-17
>END AS Newcolumn
>FROM timehd INNER JOIN timeitms
>ON Timehd.timecrdno = Timeitms.timecrdno
>WHERE Timehd.date = @dNextChkDate-6
>AND Timeitms.jobno <> 'LUNCH'
>AND
>CASE
>WHEN Timeitms.timeout>17 AND Timeitms.timein>17 THEN Timeitms.timeout-Timeitms.timein
>ELSE Timeitms.timeout-17
>END >0
>ORDER BY TIMEHD.EMPID
>
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform