Ответить на сообщение
Вернуться к теме
Вы отвечаете на сообщение:
ник: Seryoga204
Это точно, Lukas не всегда равно 0.
SELECT u.Acc AS Счет, Sum(u.Amn) AS Разница FROM ( SELECT Mid(t1.Account,3) As Acc, t1.Amount As Amn FROM New1txt t1 WHERE Left(t1.Account,2) In ('10','11') UNION ALL SELECT Mid(t2.Account,3) As 1, t2.Amount As 2 FROM New2txt t2 WHERE Left(t2.Account,2) In ('50','51') UNION ALL SELECT Mid(t3.Account,3) As 3, -t3.Amount As 4 FROM New2txt t3 WHERE Left(t3.Account,2) In ('60','61') UNION ALL SELECT Mid(t4.Account,3) As 5, -t4.Amount As 6 FROM New2txt t4 WHERE Left(t4.Account,2) In ('10','11') UNION ALL SELECT Mid(t5.Account,3) As Acc, t5.Amount As Amn FROM New1txt t5 WHERE Left(t5.Account,2) In ('20','21') UNION ALL SELECT Mid(t6.Account,3) As 1, -t6.Amount As 2 FROM New2txt t6 WHERE Left(t6.Account,2) In ('50','51') UNION ALL SELECT Mid(t7.Account,3) As 3, t7.Amount As 4 FROM New2txt t7 WHERE Left(t7.Account,2) In ('60','61') UNION ALL SELECT Mid(t8.Account,3) As 5, -t8.Amount As 6 FROM New2txt t8 WHERE Left(t8.Account,2) In ('20','21') ) u GROUP BY u.Acc ORDER BY u.Acc;
SELECT u.Acc As [Счет], Sum(u.Amn) As [Разница] FROM ( SELECT Mid(t1.Account,3) As Acc, t1.Amount As Amn FROM 1txt t1 WHERE Left(t1.Account,2) In ('20','21') UNION ALL SELECT Mid(t2.Account,3) As 1, -t2.Amount As 2 FROM 2txt t2 WHERE Left(t2.Account,2) In ('50','51') UNION ALL SELECT Mid(t3.Account,3) As 3, t3.Amount As 4 FROM 2txt t3 WHERE Left(t3.Account,2) In ('60','61') UNION ALL SELECT Mid(t4.Account,3) As 5, -t4.Amount As 6 FROM 2txt t4 WHERE Left(t4.Account,2) In ('20','21')) u Group By u.Acc Order By u.Acc
SELECT u.Acc As [Счет], Sum(u.Amn) As [Разница] FROM ( SELECT Mid(t1.Account,3) As Acc, t1.Amount As Amn FROM 1txt t1 WHERE Left(t1.Account,2) In ('10','11') UNION ALL SELECT Mid(t2.Account,3) As 1, -t2.Amount As 2 FROM 2txt t2 WHERE Left(t2.Account,2) In ('60','61') UNION ALL SELECT Mid(t3.Account,3) As 3, t3.Amount As 4 FROM 2txt t3 WHERE Left(t3.Account,2) In ('50','51') UNION ALL SELECT Mid(t4.Account,3) As 5, -t4.Amount As 6 FROM 2txt t4 WHERE Left(t4.Account,2) In ('10','11')) u Group By u.Acc Order By u.Acc
Ваше имя:
Пароль:
Сообщение:
Прикрепить:
Для вставки смайлов в текст щелкните по значку.