Hej! i sql finns inte funktion iifConvertera select-sats från Access till SQL
Jag har just bytt från access till sql och får inte till det med select-satsen...
någon som kan hjälpa mig med det?
Så här ser den ut
SELECT TOP 1 " & _
" Forum_1.ID AS ID, " & _
" IIf(IsNull(Max([Forum_2].[Datum])), [Forum_1].[Datum], Max([Forum_2].[Datum])) AS SenasteDatum, " & _
" IIf(IsNull((SELECT TOP 1 UserName FROM Forum_2 INNER JOIN Members ON Forum_2.UserID = Members.ID WHERE Forum_2.TopID = Forum_1.ID AND Forum_2.Deleted = 0)), Members.UserName, (SELECT TOP 1 UserName FROM Forum_2 INNER JOIN Members ON Forum_2.UserID = Members.ID WHERE Forum_2.TopID = Forum_1.ID AND Forum_2.Deleted = False ORDER BY Forum_2.Datum DESC)) AS SenasteNamn, " & _
" IIf(IsNull((SELECT TOP 1 Members.ID FROM Forum_2 INNER JOIN Members ON Forum_2.UserID = Members.ID WHERE Forum_2.TopID = Forum_1.ID AND Forum_2.Deleted = 0)), [Forum_1].[UserID], (SELECT TOP 1 Members.ID FROM Forum_2 INNER JOIN Members ON Forum_2.UserID = Members.ID WHERE Forum_2.TopID = Forum_1.ID AND Forum_2.Deleted = False ORDER BY Forum_2.Datum DESC)) AS SenasteNamnID " & _
" FROM " & _
" (Forum_1 LEFT JOIN Forum_2 ON ([Forum_1].[ID]=[Forum_2].[TopID] AND [Forum_2].[Deleted]=False)) LEFT JOIN Members ON [Forum_1].[UserID]=[Members].[ID] " & _
" WHERE " & _
" Forum_1.Deleted = 0 " & _
" GROUP BY " & _
" [Forum_1].[ID], " & _
" [Forum_1].[Topic], " & _
" [Forum_1].[Häftad], " & _
" [Forum_1].[HäftadTxt], " & _
" [Forum_1].[Bevakas], " & _
" [Forum_1].[Datum], " & _
" [Members].[UserName], " & _
" [Forum_1].[ForumID], " & _
" Forum_1.Visat, " & _
" [Forum_1].[UserID] " & _
" HAVING " & _
" Forum_1.ForumID=" & SelectStr(ID) & _
" ORDER BY " & _
" IIf(IsNull(Max([Forum_2].[Datum])),[Forum_1].[Datum],Max([Forum_2].[Datum])) DESC"Sv: Convertera select-sats från Access till SQL
Du skriver om följande: IIf(IsNull(Max([Forum_2].[Datum])),
till
IsNull(Max([Forum_2].[Datum]), ?och här det värde du vill att det ska få om det är NULL)
*****************************************
Från books online
ISNULL
Replaces NULL with the specified replacement value.
Syntax
ISNULL ( check_expression , replacement_value )
*************************************