experts... I have a query in Sybase as below..
SELECT h.StatusDate ,
Count(*) AS TotalLoansExported,
(SELECT COUNT(*)
FROM ezadmin.ft_LoanMaster m
WHERE (h.statusdate = m.statusdate)) AS TotalLoansImported,
(IF (TotalLoansImported > TotalLoansExported) THEN
'Duplicates exist'
ELSE
IF (TotalLoansImported = TotalLoansExported) THEN
'Imported'
ELSE
IF (TotalLoansImported = 0) THEN
'Not imported'
ENDIF
ENDIF
ENDIF) AS SystemMessage
FROM ezadmin.ft_ImportHistory h
WHERE (IALoanNum <> '')
GROUP BY h.StatusDate
ORDER BY h.StatusDate DESC
I need to convert this to SQL Server 2005/2008 format. I get the famous "multipart identifier cannot be bound" error in the first line where the h.status_date is.
How do I correct this query to make it work in SQl Server. Thanks.
SELECT h.StatusDate ,
Count(*) AS TotalLoansExported,
(SELECT COUNT(*)
FROM ezadmin.ft_LoanMaster m
WHERE (h.statusdate = m.statusdate)) AS TotalLoansImported,
CASE WHEN TotalLoansImported > TotalLoansExported THEN 'Duplicates exist'
ELSE
CASE WHEN TotalLoansImported = TotalLoansExported THEN 'Imported'
ELSE
CASE WHEN TotalLoansImported = 0 THEN 'Not imported'
END
END
END AS SystemMessage
FROM ezadmin.ft_ImportHistory h
WHERE (IALoanNum <> '')
GROUP BY h.StatusDate
ORDER BY h.StatusDate DESC