Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / Microsoft SQL Server Новый топик    Ответить
 pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
U menea esti select:

SELECT 
		isnull(Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'Brn.Filiala.Cod'),'NO BRANCH') AS 'BRANCH',
		Retail.dbo.fnGetUserProperty(U.[ID], 'EXEC') AS 'EXEC',
		'MIC_FIL' AS 'CODOP',
		Retail.dbo.fnGetWorkDay(@OpenDay) AS 'DATA',
		'06' AS 'TDOC',
		'R' AS 'VAL',
		isnull(Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), OPM.PropertyName),0) AS 'DEB',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),'MFO') AS 'MFO',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),OPM.PropertyName) AS 'CRED',
		'' AS 'CRNAME',
		'' AS 'TREZ',
		'' AS 'TRNAME',
		D.TransactionAmount - ((D.TransactionAmount * 1) / 100) AS 'SUMD',
		Retail.dbo.fnGetOrganizationProperty(D.OrganizationID, 'COMENT') + ' ' + Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName') + ' (Ag: ' + dbo.fnGetAgencyNameByUserID(M.CreateUserID) + ')' AS 'COMENT',
		Retail.dbo.fnGetOrganizationProperty(1, 'SYM') AS 'SYM',
		0 AS 'COUNTRY',
		'' AS 'CODPL',
		'' AS 'RCODE',
		0 AS 'STAT',
		'' AS 'ERR',
		'*' AS 'ZVEZ',
		Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'USIK') AS 'USIK',
		'' AS 'FKOTP',
		'' AS 'FIOOTP'	
	FROM Retail..Movements M 
		JOIN Retail..Documents D ON D.ID = M.DocumentID
		JOIN Retail..DocumentTypes DT ON DT.[ID] = D.DocumentTypeID
		JOIN RetailDTS.dbo.OrganizationPropertyMapper OPM ON D.OrganizationID = OPM.OrganizationID
		JOIN Retail..Users U ON U.[ID] = M.CreateUserID
		JOIN Retail..Organizations O ON O.ID = D.OrganizationID
	WHERE M.Direction = 1
		AND M.Amount > 0
		AND M.AmountType = 0
		AND M.IsActive = 1
		AND convert(varchar,M.RealOperationDate,105) = convert(varchar,@OpenDay,105)
		AND M.CreateUserID IN (SELECT UserID FROM Retail.dbo.fnGetAllUsersInOrganization(@FilialID))
		AND DT.[Name] IN ('QuickPay', 'QuickInvoice')
		AND dbo.fnIsOrganizationFaraContract(D.OrganizationID) = 0
		AND dbo.fnIsOrganizationATreasury(D.OrganizationID) = 0
		AND D.OrganizationID = 97
		AND
			(
				@FilialID = 2 and dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				or					
				@FilialID != 2
				and 
				dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				and
				dbo.fnCCLAnotherFIL(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'), Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'Brn.Filiala.Cod')) = 1
			)

on vozvrasciaet :

BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	279600201214				83.02140000	Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4		
BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	279600201214				55.59840000	Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4		
BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	279600201214				82.26900000	Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4		
BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	279600201214				40.25340000	Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4		
BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	279600201214				77.31900000	Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4		

mne nado iz atogo rezulitata poluiciti grupirovku po [EXEC] i polea SUMD bila prosumirovana:

BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	279600201214				338.46		Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4		

I napisal vot takoi select:

SELECT 
	BRANCH,
	[EXEC],
	CODOP,
	[DATA],
	TDOC,
	VAL,
	DEB,
	MFO,
	CRED,
	CRNAME,
	TREZ,
	TRNAME, 
	SUM(SUMD) AS 'SUMD',
	SUM(SUMD) AS 'SUMC',
	COMENT,
	SYM,
	COUNTRY,
	CODPL,
	RCODE,
	STAT,
	ERR,
	ZVEZ,
	USIK,
	FKOTP,
	FIOOTP	
FROM 
(
SELECT 
		isnull(Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'Brn.Filiala.Cod'),'NO BRANCH') AS 'BRANCH',
		Retail.dbo.fnGetUserProperty(U.[ID], 'EXEC') AS 'EXEC',
		'MIC_FIL' AS 'CODOP',
		Retail.dbo.fnGetWorkDay(@OpenDay) AS 'DATA',
		'06' AS 'TDOC',
		'R' AS 'VAL',
		isnull(Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), OPM.PropertyName),0) AS 'DEB',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),'MFO') AS 'MFO',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),OPM.PropertyName) AS 'CRED',
		'' AS 'CRNAME',
		'' AS 'TREZ',
		'' AS 'TRNAME',
		D.TransactionAmount - ((D.TransactionAmount * 1) / 100) AS 'SUMD',
		Retail.dbo.fnGetOrganizationProperty(D.OrganizationID, 'COMENT') + ' ' + Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName') + ' (Ag: ' + dbo.fnGetAgencyNameByUserID(M.CreateUserID) + ')' AS 'COMENT',
		Retail.dbo.fnGetOrganizationProperty(1, 'SYM') AS 'SYM',
		0 AS 'COUNTRY',
		'' AS 'CODPL',
		'' AS 'RCODE',
		0 AS 'STAT',
		'' AS 'ERR',
		'*' AS 'ZVEZ',
		Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'USIK') AS 'USIK',
		'' AS 'FKOTP',
		'' AS 'FIOOTP'	
	FROM Retail..Movements M 
		JOIN Retail..Documents D ON D.ID = M.DocumentID
		JOIN Retail..DocumentTypes DT ON DT.[ID] = D.DocumentTypeID
		JOIN RetailDTS.dbo.OrganizationPropertyMapper OPM ON D.OrganizationID = OPM.OrganizationID
		JOIN Retail..Users U ON U.[ID] = M.CreateUserID
		JOIN Retail..Organizations O ON O.ID = D.OrganizationID
	WHERE M.Direction = 1
		AND M.Amount > 0
		AND M.AmountType = 0
		AND M.IsActive = 1
		AND convert(varchar,M.RealOperationDate,105) = convert(varchar,@OpenDay,105)
		AND M.CreateUserID IN (SELECT UserID FROM Retail.dbo.fnGetAllUsersInOrganization(@FilialID))
		AND DT.[Name] IN ('QuickPay', 'QuickInvoice')
		AND dbo.fnIsOrganizationFaraContract(D.OrganizationID) = 0
		AND dbo.fnIsOrganizationATreasury(D.OrganizationID) = 0
		AND D.OrganizationID = 97
		AND
			(
				@FilialID = 2 and dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				or					
				@FilialID != 2
				and 
				dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				and
				dbo.fnCCLAnotherFIL(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'), Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'Brn.Filiala.Cod')) = 1
			)
) AS Subquery
GROUP BY 
	BRANCH,
	[EXEC],
	CODOP,
	[DATA],	
	TDOC,
	VAL,
	DEB,
	MFO,
	CRED,
	CRNAME,
	TREZ,
	TRNAME, 
	COMENT,
	SYM,
	COUNTRY,
	CODPL,
	RCODE,
	STAT,
	ERR,
	ZVEZ,
	USIK,
	FKOTP,
	FIOOTP	

no on vozvrasciaet ne to 4to nado:

BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	280101809				338.46		Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4
10 мар 05, 11:44    [1373960]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
Smirnov Anton
Member

Откуда: Н.Новгород
Сообщений: 3220
вы написали, что надо сгруппировать по [EXEC], а группируете по 20 полям
10 мар 05, 11:54    [1374019]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
vtoroi vlojenii select, esli posmotrite on gruperuet po

GROUP BY 
	BRANCH,
	[EXEC],
	CODOP,
	[DATA],	
	TDOC,
	VAL,
	DEB,
	MFO,
	CRED,
	CRNAME,
	TREZ,
	TRNAME, 
	COMENT,
	SYM,
	COUNTRY,
	CODPL,
	RCODE,
	STAT,
	ERR,
	ZVEZ,
	USIK,
	FKOTP,
	FIOOTP	


BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	280101809				338.46		Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4

a ndo 4tobi bilo:

BANK	Pegas_1	MIC_FIL	2005-02-25 00:00:00.000	06	R	279670001214	280101809	279600201214				338.46		Plati CCL cu contract APLP 54/198 (Ag: Pegas)	12	0			0		*	BA_DEPCON4
10 мар 05, 11:59    [1374052]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
Smirnov Anton
Member

Откуда: Н.Новгород
Сообщений: 3220
вы одну строку получаете, но неправильную сумму?
10 мар 05, 12:06    [1374087]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
v odnu strocu poluciaiu, suma pravilinaia, no:

279670001214 280101809 279600201214 - VOT TAK NADO
279670001214 280101809 280101809 - vozvasciaet select
10 мар 05, 12:09    [1374110]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
Smirnov Anton
Member

Откуда: Н.Новгород
Сообщений: 3220
как называется это поле, сумму которого нада получить
10 мар 05, 12:16    [1374153]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
polea:

             BRANCH,
	[EXEC],
	CODOP,
	[DATA],
	TDOC,
	VAL,
	DEB,
	MFO,
	CRED,
	CRNAME,
	TREZ,
	TRNAME, 
	SUMD,
	SUMC,
	COMENT,
	SYM,
	COUNTRY,
	CODPL,
	RCODE,
	STAT,
	ERR,
	ZVEZ,
	USIK,
	FKOTP,
	FIOOTP	

sprava na levo
10 мар 05, 12:33    [1374239]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
Smirnov Anton
Member

Откуда: Н.Новгород
Сообщений: 3220
ничего не понимаю
вы хотите получить сумму по полю SUMD в результате группировки?
ЗЫ
	SUM(SUMD) AS 'SUMD',
	SUM(SUMD) AS 'SUMC',
может во второй строке другое поле нада указать???
10 мар 05, 12:46    [1374322]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
da
10 мар 05, 13:47    [1374619]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
Smirnov Anton
Member

Откуда: Н.Новгород
Сообщений: 3220
da - надо понимать, что надо получить сумму по полю SUMD
поробуйте вот етот запрос, что он вернёт
SELECT 
	[EXEC],
	SUM(SUMD) AS 'SUMD'
FROM 
(
SELECT 
		Retail.dbo.fnGetUserProperty(U.[ID], 'EXEC') AS 'EXEC',
		D.TransactionAmount - ((D.TransactionAmount * 1) / 100) AS 'SUMD'	
	FROM Retail..Movements M 
		JOIN Retail..Documents D ON D.ID = M.DocumentID
		JOIN Retail..DocumentTypes DT ON DT.[ID] = D.DocumentTypeID
		JOIN RetailDTS.dbo.OrganizationPropertyMapper OPM ON D.OrganizationID = OPM.OrganizationID
		JOIN Retail..Users U ON U.[ID] = M.CreateUserID
		JOIN Retail..Organizations O ON O.ID = D.OrganizationID
	WHERE M.Direction = 1
		AND M.Amount > 0
		AND M.AmountType = 0
		AND M.IsActive = 1
		AND convert(varchar,M.RealOperationDate,105) = convert(varchar,@OpenDay,105)
		AND M.CreateUserID IN (SELECT UserID FROM Retail.dbo.fnGetAllUsersInOrganization(@FilialID))
		AND DT.[Name] IN ('QuickPay', 'QuickInvoice')
		AND dbo.fnIsOrganizationFaraContract(D.OrganizationID) = 0
		AND dbo.fnIsOrganizationATreasury(D.OrganizationID) = 0
		AND D.OrganizationID = 97
		AND
			(
				@FilialID = 2 and dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				or					
				@FilialID != 2
				and 
				dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				and
				dbo.fnCCLAnotherFIL(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'), Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'Brn.Filiala.Cod')) = 1
			)
) AS Subquery
GROUP BY 
	[EXEC]
10 мар 05, 13:52    [1374649]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
SELECT 
		Retail.dbo.fnGetUserProperty(U.[ID], 'EXEC') AS 'EXEC',
		D.TransactionAmount - ((D.TransactionAmount * 1) / 100) AS 'SUMD',
		isnull(Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), OPM.PropertyName),0) AS 'DEB',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),'MFO') AS 'MFO',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),OPM.PropertyName) AS 'CRED'
	FROM Retail..Movements M 
		JOIN Retail..Documents D ON D.ID = M.DocumentID
		JOIN Retail..DocumentTypes DT ON DT.[ID] = D.DocumentTypeID
		JOIN RetailDTS.dbo.OrganizationPropertyMapper OPM ON D.OrganizationID = OPM.OrganizationID
		JOIN Retail..Users U ON U.[ID] = M.CreateUserID
		JOIN Retail..Organizations O ON O.ID = D.OrganizationID
	WHERE M.Direction = 1
		AND M.Amount > 0
		AND M.AmountType = 0
		AND M.IsActive = 1
		AND convert(varchar,M.RealOperationDate,105) = convert(varchar,@OpenDay,105)
		AND M.CreateUserID IN (SELECT UserID FROM Retail.dbo.fnGetAllUsersInOrganization(@FilialID))
		AND DT.[Name] IN ('QuickPay', 'QuickInvoice')
		AND dbo.fnIsOrganizationFaraContract(D.OrganizationID) = 0
		AND dbo.fnIsOrganizationATreasury(D.OrganizationID) = 0
		AND D.OrganizationID = 97
		AND
			(
				@FilialID = 2 and dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				or					
				@FilialID != 2
				and 
				dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				and
				dbo.fnCCLAnotherFIL(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'), Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'Brn.Filiala.Cod')) = 1
			)

Vozvosciaet:

Pegas_1	83.02140000	279670001214	280101809	279600201214
Pegas_1	55.59840000	279670001214	280101809	279600201214
Pegas_1	82.26900000	279670001214	280101809	279600201214
Pegas_1	40.25340000	279670001214	280101809	279600201214
Pegas_1	77.31900000	279670001214	280101809	279600201214

select:

SELECT 
	[EXEC],
	SUM(SUMD) AS 'SUMD',
	DEB,
	MFO,
	CRED
FROM 
(
SELECT 
		Retail.dbo.fnGetUserProperty(U.[ID], 'EXEC') AS 'EXEC',
		D.TransactionAmount - ((D.TransactionAmount * 1) / 100) AS 'SUMD',
		isnull(Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), OPM.PropertyName),0) AS 'DEB',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),'MFO') AS 'MFO',
		RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),OPM.PropertyName) AS 'CRED'
	FROM Retail..Movements M 
		JOIN Retail..Documents D ON D.ID = M.DocumentID
		JOIN Retail..DocumentTypes DT ON DT.[ID] = D.DocumentTypeID
		JOIN RetailDTS.dbo.OrganizationPropertyMapper OPM ON D.OrganizationID = OPM.OrganizationID
		JOIN Retail..Users U ON U.[ID] = M.CreateUserID
		JOIN Retail..Organizations O ON O.ID = D.OrganizationID
	WHERE M.Direction = 1
		AND M.Amount > 0
		AND M.AmountType = 0
		AND M.IsActive = 1
		AND convert(varchar,M.RealOperationDate,105) = convert(varchar,@OpenDay,105)
		AND M.CreateUserID IN (SELECT UserID FROM Retail.dbo.fnGetAllUsersInOrganization(@FilialID))
		AND DT.[Name] IN ('QuickPay', 'QuickInvoice')
		AND dbo.fnIsOrganizationFaraContract(D.OrganizationID) = 0
		AND dbo.fnIsOrganizationATreasury(D.OrganizationID) = 0
		AND D.OrganizationID = 97
		AND
			(
				@FilialID = 2 and dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				or					
				@FilialID != 2
				and 
				dbo.fnIsCCLInFil9(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName')) = 0
				and
				dbo.fnCCLAnotherFIL(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'), Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), 'Brn.Filiala.Cod')) = 1
			)
) AS Subquery
GROUP BY 
	[EXEC],
	DEB,
	CRED,
	MFO

vozvrosciaet:

Pegas_1	338.46120000	279670001214	279600201214	279600201214

togda kak nado 4tobi vozvroscial:

Pegas_1	338.46120000	279670001214	280101809	279600201214


Pocemu v pole MFO i poluciaiu znacenia polea CRED??
10 мар 05, 14:31    [1374894]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
Smirnov Anton
Member

Откуда: Н.Новгород
Сообщений: 3220
ну это вовсе фокусф какие-то
вы где проверяете, что он выдаёт такой результат?
10 мар 05, 14:52    [1375017]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
SQL QUERY ANALYSER
10 мар 05, 14:55    [1375037]     Ответить | Цитировать Сообщить модератору
 Re: pomoghite s zaprosom  [new]
gda
Member

Откуда:
Сообщений: 985
esli stavliu substring:

SELECT 
		Retail.dbo.fnGetUserProperty(U.[ID], 'EXEC') AS 'EXEC',
		D.TransactionAmount - ((D.TransactionAmount * 1) / 100) AS 'SUMD',
		substring(isnull(Retail.dbo.fnGetOrganizationProperty(Retail.dbo.GetHigherOrganizationIDByLevelTypeID(U.OrganizationID, 2), OPM.PropertyName),0),1,12) AS 'DEB',
		substring(RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),'MFO'),1,9) AS 'MFO',
		substring(RetailDTS.dbo.fnGetCCLOrgProperty(RetailDTS.dbo.fnGetCCLProperty(D.OrganizationID, Retail.dbo.fnGetDocumentProperty(D.[ID],'CCLName'),'Head.Filial'),OPM.PropertyName),1,12) AS 'CRED'
	FROM Retail..Movements M 
...

to vse vozvrasciaet kak nado ... no substring mne ne podhodit ...
10 мар 05, 14:57    [1375050]     Ответить | Цитировать Сообщить модератору
Все форумы / Microsoft SQL Server Ответить