Click here to Skip to main content
14,739,263 members
Home » Discussions » Database
   

Database

 
AnswerRe: Tables left and right Pin
Richard MacCutchan5-Feb-19 7:10
mveRichard MacCutchan5-Feb-19 7:10 
AnswerRe: Tables left and right Pin
ZurdoDev7-Feb-19 5:41
professionalZurdoDev7-Feb-19 5:41 
QuestionUsing JSON functions with Always Encrypted data in SSMS Pin
Hypermommy4-Feb-19 7:06
MemberHypermommy4-Feb-19 7:06 
AnswerRe: Using JSON functions with Always Encrypted data in SSMS Pin
Richard Deeming4-Feb-19 10:20
mveRichard Deeming4-Feb-19 10:20 
GeneralRe: Using JSON functions with Always Encrypted data in SSMS Pin
Hypermommy6-Feb-19 3:38
MemberHypermommy6-Feb-19 3:38 
Questiondatabase Pin
Member 141284154-Feb-19 7:03
MemberMember 141284154-Feb-19 7:03 
AnswerRe: database Pin
Jörgen Andersson4-Feb-19 9:41
professionalJörgen Andersson4-Feb-19 9:41 
QuestionHaving difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 3:37
Memberpaul4everyone28-Jan-19 3: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 3:56
mveRichard MacCutchan28-Jan-19 3:56 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 5:20
Memberpaul4everyone28-Jan-19 5:20 
SuggestionRe: Having difficulty to replicate entries in SQL query result Pin
ZurdoDev28-Jan-19 5:48
professionalZurdoDev28-Jan-19 5:48 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 7:54
Memberpaul4everyone28-Jan-19 7:54 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Richard MacCutchan28-Jan-19 7:01
mveRichard MacCutchan28-Jan-19 7:01 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 7:51
Memberpaul4everyone28-Jan-19 7:51 
AnswerRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes28-Jan-19 12:02
professionalMycroft Holmes28-Jan-19 12:02 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone28-Jan-19 16:02
Memberpaul4everyone28-Jan-19 16:02 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes29-Jan-19 11:58
professionalMycroft Holmes29-Jan-19 11:58 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone31-Jan-19 11:50
Memberpaul4everyone31-Jan-19 11:50 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes31-Jan-19 12:15
professionalMycroft Holmes31-Jan-19 12:15 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
paul4everyone2-Feb-19 20:03
Memberpaul4everyone2-Feb-19 20:03 
GeneralRe: Having difficulty to replicate entries in SQL query result Pin
Mycroft Holmes2-Feb-19 20:29
professionalMycroft Holmes2-Feb-19 20:29 
Questionis it safe to use this with sql server and entity framework ? Pin
desanti9-Jan-19 15:38
Memberdesanti9-Jan-19 15:38 
AnswerRe: is it safe to use this with sql server and entity framework ? Pin
Mycroft Holmes9-Jan-19 20:51
professionalMycroft Holmes9-Jan-19 20:51 
AnswerRe: is it safe to use this with sql server and entity framework ? Pin
Eddy Vluggen10-Jan-19 3:17
professionalEddy Vluggen10-Jan-19 3:17 
QuestionGetting error in SQL 2012 working fine in 2016 Pin
GaneshVidiyala25-Dec-18 22:41
professionalGaneshVidiyala25-Dec-18 22: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.