Click here to Skip to main content
15,913,939 members
Home / Discussions / Database
   

Database

 
GeneralCRecordSet and requery Pin
pnpfriend24-Mar-04 4:44
pnpfriend24-Mar-04 4:44 
GeneralRe: CRecordSet and requery Pin
kzyczynski24-Mar-04 6:23
kzyczynski24-Mar-04 6:23 
GeneralContinuous Datagrid update Pin
JM_FL24-Mar-04 1:10
JM_FL24-Mar-04 1:10 
GeneralRe: Continuous Datagrid update Pin
Mike Dimmick24-Mar-04 1:58
Mike Dimmick24-Mar-04 1:58 
GeneralAcess Workflow and SQL 8.0 Pin
vikramlinux23-Mar-04 18:19
vikramlinux23-Mar-04 18:19 
GeneralOleDbAdapter.Update problem Pin
Tristan Rhodes23-Mar-04 10:35
Tristan Rhodes23-Mar-04 10:35 
GeneralRe: OleDbAdapter.Update problem Pin
Edbert P23-Mar-04 11:35
Edbert P23-Mar-04 11:35 
GeneralRe: OleDbAdapter.Update problem Pin
Tristan Rhodes24-Mar-04 11:53
Tristan Rhodes24-Mar-04 11:53 
GeneralConnectionless recordset error Pin
Adam Gritt23-Mar-04 4:35
Adam Gritt23-Mar-04 4:35 
GeneralRe: Connectionless recordset error Pin
Mike Dimmick24-Mar-04 2:13
Mike Dimmick24-Mar-04 2:13 
GeneralRe: Connectionless recordset error Pin
Adam Gritt24-Mar-04 3:29
Adam Gritt24-Mar-04 3:29 
Generalmoving in mfc recordset Pin
kzyczynski23-Mar-04 4:04
kzyczynski23-Mar-04 4:04 
GeneralRe: moving in mfc recordset Pin
DiWa25-Mar-04 8:33
DiWa25-Mar-04 8:33 
GeneralRe: moving in mfc recordset Pin
kzyczynski26-Mar-04 3:19
kzyczynski26-Mar-04 3:19 
GeneralI need Free SQL Server 2000 EBook Pin
xstoneheartx22-Mar-04 23:52
xstoneheartx22-Mar-04 23:52 
GeneralRe: I need Free SQL Server 2000 EBook Pin
Mike Dimmick23-Mar-04 3:54
Mike Dimmick23-Mar-04 3:54 
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 

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.