Click here to Skip to main content
14,176,979 members
   

Database

 
AnswerRe: Tables left and right Pin
Richard MacCutchan5-Feb-19 6:10
protectorRichard MacCutchan5-Feb-19 6:10 
AnswerRe: Tables left and right Pin
ZurdoDev7-Feb-19 4:41
professionalZurdoDev7-Feb-19 4:41 
QuestionUsing JSON functions with Always Encrypted data in SSMS Pin
Hypermommy4-Feb-19 6:06
memberHypermommy4-Feb-19 6:06 
AnswerRe: Using JSON functions with Always Encrypted data in SSMS Pin
Richard Deeming4-Feb-19 9:20
mveRichard Deeming4-Feb-19 9:20 
GeneralRe: Using JSON functions with Always Encrypted data in SSMS Pin
Hypermommy6-Feb-19 2:38
memberHypermommy6-Feb-19 2:38 
Questiondatabase Pin
Member 141284154-Feb-19 6:03
memberMember 141284154-Feb-19 6:03 
AnswerRe: database Pin
Jörgen Andersson4-Feb-19 8:41
protectorJörgen Andersson4-Feb-19 8:41 
QuestionHaving difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 2:37
memberpaul4everyone28-Jan-19 2:37 
Good day all!
Please assist if you can in resolving this my SQL query difficulty.
I have 2 query results as follows;


Table A
CID | NAME | CREDENTIAL | BAL | GID1 | GID2 | UNIQUE_ID
01 | AAA | debtor | 20 | 03 | 02 | 01-03,02
02 | BBB | debtor | 15 | 01 | 05 | 02-01,05
03 | CCC | debtor | 10 | 02 | 04 | 03-02,04

TABLE B
CID | NAME | BAL
01 | AAA | 20
02 | BBB | 15
03 | CCC | 10
04 | DDD | 5
05 | EEE | 2
06 | FFF | 4

Now I need help in getting TABLE C that should look like this;

CID | NAME | CREDENTIAL | BAL | UNIQUE_ID
01 | AAA | debtor | 20 | 01-03,02
03 | CCC | guarantor | 10 | 01-03,02
02 | BBB | guarantor | 15 | 01-03,02

02 | BBB | debtor | 15 | 02-01,05
01 | AAA | guarantor | 20 | 02-01,05
05 | EEE | guarantor | 2 | 02-01,05

03 | CCC | debtor | 10 | 03-02,04
02 | BBB | guarantor | 15 | 03-02,04
04 | DDD | guarantor | 5 | 03-02,04

WHAT I INTEND TO ACHIEVE
This is like a loan collection summary.
CID = General Primary Key for every customer
NAME = Customer names
CREDENTIAL = To help me diffentiate between the loan collector and the guarantors, so that I can group in my front end VB application.
BAL = everyone account balance
GID = guarantor for the loan collector, GID is a subset of CID
UNIQUE_ID = A string to combine the CID and the GID for a loan transaction so that I can easily isolate everything about a single loan transaction.

Table A is an abridged form of each loan collection transaction.
Table B carries the account balance for every customer.
Now, I expect Table C to carry all loan record in Table A and use the entries in GID1 and GID2 columns to fetch their corresponding details from Table B while retaining the Unique_ID entries from Table A so that sorting by Unique_ID will bring all loans together.

Please assist me with a way to achieve this, I have been thinking for days, yet no breakthrough.
Thanks in advance

modified 28-Jan-19 21:07pm.

AnswerRe: Having difficulty to replicate entries in SQL query result Pin
Richard MacCutchan28-Jan-19 2:56
protectorRichard MacCutchan28-Jan-19 2:56 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 4:20
memberpaul4everyone28-Jan-19 4:20 
SuggestionRe: Having difficulty to replicate entries in SQL query result Pin
ZurdoDev28-Jan-19 4:48
professionalZurdoDev28-Jan-19 4:48 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 6:54
memberpaul4everyone28-Jan-19 6:54 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Richard MacCutchan28-Jan-19 6:01
protectorRichard MacCutchan28-Jan-19 6:01 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 6:51
memberpaul4everyone28-Jan-19 6:51 
AnswerRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes28-Jan-19 11:02
memberMycroft Holmes28-Jan-19 11:02 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 15:02
memberpaul4everyone28-Jan-19 15:02 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes29-Jan-19 10:58
memberMycroft Holmes29-Jan-19 10:58 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone31-Jan-19 10:50
memberpaul4everyone31-Jan-19 10:50 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes31-Jan-19 11:15
memberMycroft Holmes31-Jan-19 11:15 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone2-Feb-19 19:03
memberpaul4everyone2-Feb-19 19:03 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes2-Feb-19 19:29
memberMycroft Holmes2-Feb-19 19:29 
Questionis it safe to use this with sql server and entity framework ? Pin
desanti9-Jan-19 14:38
memberdesanti9-Jan-19 14:38 
AnswerRe: is it safe to use this with sql server and entity framework ? Pin
Mycroft Holmes9-Jan-19 19:51
memberMycroft Holmes9-Jan-19 19:51 
AnswerRe: is it safe to use this with sql server and entity framework ? Pin
Eddy Vluggen10-Jan-19 2:17
mveEddy Vluggen10-Jan-19 2:17 
QuestionGetting error in SQL 2012 working fine in 2016 Pin
GaneshVidiyala25-Dec-18 21:41
professionalGaneshVidiyala25-Dec-18 21: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.


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190526.1 | Last Updated 24 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid