March 31, 2011 at 11:14 am
I'm new in this field of sql I have this problem in a development that I have in my charge.
I have this query. a customer can have many bills, some canceled subscriptions and others with no other fertilizer.
this is my sp, which is the difficulty I see is that as a filter for the customer id this brings me and show me all the bills that have fertilizers, which do not have tickets, and canceled the entire customer history in the billing and my users would not be functional also show you the bills are already paid.
that is what I want to sp that every time I see the client alone, and show me the bills on a grid with fertilizers and have no fertilizers, not the show canceled.
any idea how to do it, any suggestions will be really well received.
Million Thanks.
ALTER PROCEDURE [dbo]. [FACTCLIENT_GRID_S]
@ IntCodigo_CLIE varchar (20)
- @ IntTIDO int
AS
BEGIN
- SET NOCOUNT ON added to Prevent extra result sets from
- Interfering with SELECT statements.
SET NOCOUNT ON;
- Insert statements for procedure here
SELECT DISTINCT tblFACTura.intCodigo_FACT, intNumero_FACT AS [INVOICE NUM] dtmFecha_FACT AS [DATE INVOICE] AS dtmFechaRadicado_FACT FECHA_RADICA,
dtmFechaVenc_FACT AS [MATURITY DATE], tblCLIEnte.strNombre_CLIE AS CUSTOMER AS tblABonoFActura.dcmSaldo_AB BALANCE
'BILLS PORTFOLIO' =
CASE WHEN (SUM (tblDetalle.dcmBruto_DETA) = (SUM (tblABonoFActura.dcmValorAbono_AB)) AND (tblABonoFActura.dcmSaldo_AB) = 0) THEN 'INVOICE CANCELLED'
ELSE 'INVOICE PENDIENTE'END
TblDetalle tblFACTura FROM INNER JOIN ON
T = tblFACTura.intCodigo_FAC tblDetalle.intCodigo_FACT
INNER JOIN ON tblCLIEnte tblFACTura.intCodigo_CLIE = tblCLIEnte.intCodigo_CLI E tblABonoFActura ON FULL JOIN
tblFACTura.intCodigo_FACT = tblABonoFActura.intCodig o_FACT
WHERE / * tblABonoFActura.intCodigoAbono_AB IS NULL AND * / tblFACTura.intCodigo_CLIE = @ intCodigo_CLIE - AND tblABonoFActura.dcmValorAbono_AB <> 0
GROUP BY tblFACTura.intCodigo_FACT, intNumero_FACT, dtmFecha_ FACT dtmFechaRadicado_FACT, dtmFechaDocumento_AB, dt mFechaVenc_FACT, strNombre_CLIE, dcmSaldo_AB
BY ORDER intNumero_FACT
END
April 1, 2011 at 6:37 am
Thank you very much for your contribution to me is more than Valis, if he is right I have to learn from those who know, I know my code is a mess as you say, and try to improve every day going to these forums and with contributions as significant as yours.
appreciate your help
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply