Click here to Skip to main content
15,891,253 members
Home / Discussions / Database
   

Database

 
GeneralRe: I need Free SQL Server 2000 EBook Pin
Sarvesvara (BVKS) Dasa27-Mar-04 3:07
Sarvesvara (BVKS) Dasa27-Mar-04 3:07 
GeneralMonth to date in SP Pin
Anonymous22-Mar-04 10:26
Anonymous22-Mar-04 10:26 
GeneralRe: Month to date in SP Pin
Edbert P22-Mar-04 11:27
Edbert P22-Mar-04 11:27 
GeneralRe: Month to date in SP Pin
michanne26-Mar-04 2:58
michanne26-Mar-04 2:58 
GeneralSQL For Smarties Pin
afronaut22-Mar-04 10:00
afronaut22-Mar-04 10:00 
GeneralRe: SQL For Smarties Pin
Edbert P22-Mar-04 11:16
Edbert P22-Mar-04 11:16 
GeneralRe: SQL For Smarties Pin
afronaut22-Mar-04 11:42
afronaut22-Mar-04 11:42 
GeneralRe: SQL For Smarties Pin
Edbert P22-Mar-04 12:08
Edbert P22-Mar-04 12:08 
Sorry, it was 9AM in the morning and I haven't had my coffee Poke tongue | ;-P

Yes, COALESCE is meant to return the first non-null value from the values passed.

Have a look at this code:
SELECT TOP 3 @TotalLoanValue = COALESCE(@TotalLoanValue + ', ', '') + loanvalue

The first time the @TotalLoanValue variable is processed, it will return NULL as the value. I use COALESCE to return empty string ('') instead, so when I concatenate the next rows, they will not result in null.
You can also use ISNULL(@TotalLoanValue + ', ', '') instead of COALESCE(@TotalLoanValue + ', ', '') as they're basically doing the same thing, except that ISNULL only accepts two values.

What the whole SQL statement does is just to concatenate the result of the query into one comma-delimited string. Just change the delimiter if you need to.

Good luck! Big Grin | :-D

PS: Use WHERE loanvalue IS NOT NULL if you want to always return 3 records.

Edbert P.
Sydney, Australia.
GeneralRe: SQL For Smarties Pin
Bill Dean8-Apr-04 1:59
Bill Dean8-Apr-04 1:59 
GeneralNeed some understanding on SP Pin
Tom Wright22-Mar-04 7:14
Tom Wright22-Mar-04 7:14 
GeneralRe: Need some understanding on SP Pin
OMalleyW25-Mar-04 2:41
OMalleyW25-Mar-04 2:41 
GeneralFoxpro (free) Tables and ADO.NET Pin
ArnieA21-Mar-04 19:56
ArnieA21-Mar-04 19:56 
GeneralBackup/Restore Database in ISP Pin
Clickok20-Mar-04 15:02
Clickok20-Mar-04 15:02 
GeneralRe: Backup/Restore Database in ISP Pin
Mike Dimmick22-Mar-04 4:55
Mike Dimmick22-Mar-04 4:55 
GeneralInserting Soap formatted XML into SQLServer2K table Pin
atan_ban20-Mar-04 7:26
atan_ban20-Mar-04 7:26 
GeneralRe: Inserting Soap formatted XML into SQLServer2K table Pin
Mazdak20-Mar-04 21:00
Mazdak20-Mar-04 21:00 
GeneralSending Data to URL Pin
SamAmman19-Mar-04 20:47
SamAmman19-Mar-04 20:47 
GeneralUpdating cells in datagrid base off another cells input value Pin
Anonymous19-Mar-04 7:05
Anonymous19-Mar-04 7:05 
GeneralODBC join Pin
Ganesh Ramaswamy19-Mar-04 6:35
Ganesh Ramaswamy19-Mar-04 6:35 
GeneralRe: ODBC join Pin
Mike Dimmick19-Mar-04 11:40
Mike Dimmick19-Mar-04 11:40 
GeneralSQL Server 7 to 2000 Pin
hxxbin19-Mar-04 4:31
hxxbin19-Mar-04 4:31 
GeneralRe: SQL Server 7 to 2000 Pin
Rob Graham19-Mar-04 10:53
Rob Graham19-Mar-04 10:53 
GeneralRe: SQL Server 7 to 2000 Pin
Jeff Varszegi20-Mar-04 4:48
professionalJeff Varszegi20-Mar-04 4:48 
QuestionHow to use SQL server CE in embedded visual c++? Pin
P_JAYAPRAKASH19-Mar-04 0:53
P_JAYAPRAKASH19-Mar-04 0:53 
QuestionLocale of DataSet effects datetime values? Pin
JackDotNet18-Mar-04 8:41
JackDotNet18-Mar-04 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.