Click here to Skip to main content
15,844,156 members
Home / Discussions / Database
   

Database

 
QuestionSQL statements Pin
Erick Kaira27-May-21 9:09
Erick Kaira27-May-21 9:09 
AnswerRe: SQL statements Pin
Victor Nijegorodov27-May-21 9:40
Victor Nijegorodov27-May-21 9:40 
AnswerRe: SQL statements Pin
SeanChupas27-May-21 10:02
SeanChupas27-May-21 10:02 
QuestionRe: SQL statements Pin
David Crow27-May-21 10:12
David Crow27-May-21 10:12 
AnswerRe: SQL statements Pin
Mycroft Holmes27-May-21 13:19
professionalMycroft Holmes27-May-21 13:19 
QuestionSQL query dilemma Pin
David Crow20-May-21 11:31
David Crow20-May-21 11:31 
AnswerRe: SQL query dilemma Pin
Mycroft Holmes20-May-21 14:05
professionalMycroft Holmes20-May-21 14:05 
QuestionAccounting problem in SQL Pin
Member 1400680616-May-21 0:23
Member 1400680616-May-21 0:23 
Hello everyone .
I have an accounting calculation problem. I want to write it with SQL Query (in ssms).
I have two groups of documents related to one person (creditor and debtor)
Creditor documents cover debtor documents.
Consider the following example: (How can the result be achieved?) 


SQL
USE [master]
GO

DROP TABLE IF EXISTS #credit/*creditor=0*/,#debit/*Debtor=1*/

SELECT *
INTO #debit
FROM 	(values 
		(88,'2/14',1,5,1),(88,'2/15',2,5,1)
		)A (personID,DocDate,DocID,Fee,IsDebit)

SELECT *
INTO #credit
FROM 	(values 
		(88,'2/16',3,3,0),(88,'2/17',4,7,0)
		)A (personID,DocDate,DocID,Fee,ISDeb)
SELECT * FROM #credit
SELECT * FROM #debit


--result:
;WITH res AS
(
	SELECT 88 AS personID ,1 deb_DocID ,5 deb_Fee , 3 Cre_DocID ,3 Cre_Fee, 0 remain_Cre_Fee
	UNION
	SELECT 88 AS personID ,1 deb_DocID ,5 deb_Fee , 4 Cre_DocID ,7 Cre_Fee, 5 remain_Cre_Fee
	UNION
	SELECT 88 AS personID ,2 deb_DocID ,5 deb_Fee , 4 Cre_DocID ,7 Cre_Fee, 0 remain_Cre_Fee
)


SELECT *
FROM res

AnswerRe: Accounting problem in SQL Pin
Mycroft Holmes16-May-21 13:17
professionalMycroft Holmes16-May-21 13:17 
AnswerRe: Accounting problem in SQL Pin
CHill6019-May-21 3:55
mveCHill6019-May-21 3:55 
QuestionSQL Server Execution Timeout Expired Pin
idkd13-May-21 0:00
idkd13-May-21 0:00 
AnswerRe: SQL Server Execution Timeout Expired Pin
SeanChupas13-May-21 2:49
SeanChupas13-May-21 2:49 
QuestionIn-memory database with acid transactions and high availability Pin
Mathieu Seillier12-May-21 3:54
Mathieu Seillier12-May-21 3:54 
AnswerRe: In-memory database with acid transactions and high availability Pin
Mycroft Holmes12-May-21 14:00
professionalMycroft Holmes12-May-21 14:00 
AnswerRe: In-memory database with acid transactions and high availability Pin
Richard MacCutchan12-May-21 22:08
mveRichard MacCutchan12-May-21 22:08 
AnswerRe: In-memory database with acid transactions and high availability Pin
Meysam Toluie29-Jan-22 0:06
Meysam Toluie29-Jan-22 0:06 
GeneralRe: In-memory database with acid transactions and high availability Pin
OriginalGriff29-Jan-22 0:08
mveOriginalGriff29-Jan-22 0:08 
GeneralRe: In-memory database with acid transactions and high availability Pin
Meysam Toluie29-Jan-22 0:25
Meysam Toluie29-Jan-22 0:25 
QuestionSQL Server round trip issue between server and client pc Pin
Mou_kol1-May-21 7:35
Mou_kol1-May-21 7:35 
AnswerRe: SQL Server round trip issue between server and client pc Pin
Mycroft Holmes1-May-21 12:57
professionalMycroft Holmes1-May-21 12:57 
AnswerRe: SQL Server round trip issue between server and client pc Pin
Gerry Schmitz1-May-21 18:12
mveGerry Schmitz1-May-21 18:12 
GeneralRe: SQL Server round trip issue between server and client pc Pin
Mycroft Holmes2-May-21 13:24
professionalMycroft Holmes2-May-21 13:24 
GeneralRe: SQL Server round trip issue between server and client pc Pin
Gerry Schmitz2-May-21 19:53
mveGerry Schmitz2-May-21 19:53 
QuestionSqlServer (and ADO.NET) mystery... Pin
Super Lloyd27-Apr-21 20:19
Super Lloyd27-Apr-21 20:19 
AnswerRe: SqlServer (and ADO.NET) mystery... Pin
Richard Deeming27-Apr-21 23:11
mveRichard Deeming27-Apr-21 23:11 

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.