Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Converti colonna in stringa in SQL Select

Per concatenare i numeri in MSSQL-2005 dovresti usare CAST

CAST(loginsFailed AS VARCHAR(10)) + '/' + CAST(LoginCount AS VARCHAR(10))

loginsFailed e loginCount sopra è in realtà il tuo select count distinct frammenti

Spero che funzioni

CAST ((SELECT COUNT(DISTINCT loginsFailed) FROM users WHERE users.employeedID = userDetails.employeeID AND users.startdate = 01-01-2013) AS VARCHAR(10))
+ '/' +
CAST ((SELECT COUNT(DISTINCT logins) FROM users WHERE users.employeedID = userDetails.employeeID AND users.startdate = 01-01-2013) AS VARCHAR(10))