Está en la página 1de 5

BUSCANDO POR LETRA

CREATE PROCEDURE PRUEBAALFREDO


@BUSCA VARCHAR(20)
AS
SELECT ct_a0005usuarios.cod_usuario, nombre , Dni,cargo, Telefono AS
Anexo,usuario,clave,Fecha_Registro , a_contabilidad AS GG
FROM ct_a0005usuarios
INNER JOIN ct_a0005usuarios_registros
ON ct_a0005usuarios.cod_usuario = ct_a0005usuarios_registros.cod_usuario
INNER JOIN ct_a0005usuarios_permisos
ON ct_a0005usuarios_registros.cod_usuario =
ct_a0005usuarios_permisos.cod_usuario
WHERE ct_a0005usuarios.nombre LIKE @BUSCA + '%'

EXEC PRUEBAALFREDO 'F'

BUSCANDO POR LETRA

SELECT ct_a0005usuarios.cod_usuario, nombre , ISNULL(Dni,'') AS DNI


,cargo, ISNULL(Telefono,'') AS
Anexo,usuario,clave,ISNULL(Fecha_Registro,'') , a_contabilidad AS GG
FROM ct_a0005usuarios
INNER JOIN ct_a0005usuarios_registros
ON ct_a0005usuarios.cod_usuario = ct_a0005usuarios_registros.cod_usuario
INNER JOIN ct_a0005usuarios_permisos
ON ct_a0005usuarios_registros.cod_usuario =
ct_a0005usuarios_permisos.cod_usuario
-----------------------------------------------------------------------------------------------------------------------------------

SELECT Ct_Fecha AS FECHA, CT_FechaReg as 'HORA' FROM CT_A0005CRUTA

SELECT CONVERT(VARCHAR(10),Ct_Fecha,103) AS FECHA,


CONVERT(VARCHAR(10),CT_FechaReg,108) as 'HORA' FROM CT_A0005CRUTA

-----------------------------------------------------------------------------------------------------------------------------------

select isnull(Ct_HorSal,'')from CT_A0005DETRUTA where Ct_RucCli =


20108552337 or Ct_RucCli= 20143920764

select isnull(cast(Ct_HorSal as varchar(5)),'') 'HOR SAL' from


CT_A0005DETRUTA where Ct_RucCli = 20108552337 or Ct_RucCli= 20143920764

select CO_CTIPOC,(case CO_CTIPOC when 'COMPRA NACIONAL' then 'NA' else


'AA' end) as tipo from OC0005MCAB
SELECT CONVERT(VARCHAR(20),ct_dfeccot,108) as 'Hora Cotizacion' FROM
CT_COTCAB WHERE CT_CNUMCOT = 2013004210

SELECT substring(convert(varchar(8),ct_dfeccot,108),1,5) as 'Hora


Cotizacion' FROM CT_COTCAB WHERE CT_CNUMCOT = 2013004210

SELECT
T.Ct_NroPed AS 'Nro. Orden Venta',
CONVERT(VARCHAR(20),T.Ct_FechaPed,103) AS 'FECHA',
CONVERT(VARCHAR(20),T.Ct_FechaPed,108) AS 'HORA',
(SELECT COUNT(*) FROM CT_A0005DETPEDIDO X WHERE X.Ct_NroPed=T.Ct_NroPED)
AS 'Cantidad de Item',
ISNULL((SELECT sum(Ct_NroPza) FROM CT_A0005DETPEDIDO X WHERE
X.Ct_NroPed=T.Ct_NroPED),'') AS 'Cantidad de Piezas',
'','',T.CT_RAZONCLI,T.CT_PARTIDA,'','',T.CT_LLEGADA,'','',T.CT_ESTADOPED
FROM
CT_A0005CPEDIDO T LEFT OUTER JOIN
CT_A0005CPICKING T1 ON T.Ct_NroPed=T1.Ct_NroPed

SELECT ROW_NUMBER() OVER(ORDER BY LT_DFECLET DESC) AS


'Items','PENDIENTE'AS'Estado',LT_DFECLET AS 'Vencimiento',
LT_NIMPTMN AS 'Soles',LT_NIMPTUS AS 'Dolares',LT_NTIPCAM AS 'T.C',
LT_CNROLET AS 'N Letra' FROM CC0005LETR
WHERE LT_CNROLET IN('0038315-00','0038316-00')
SELECT RIGHT('0000000'+LTRIM(LEFT(MAX(LT_CNROLET),6)+1),7)+'-00' FROM CC0005LETR

select TD_CTIPDOC as 'TD',


TD_CNRODOC AS 'Nro.Documento',
CONVERT(VARCHAR(20),TD_DFECDOC,103) AS 'Fecha Dcmto.',
CONVERT(VARCHAR(20),TD_DFECVEN,103) AS 'Fecha Vmto.',
TD_CTIPMON AS 'Mon',
TD_NIMPORT as 'Importe',
TD_CORGDES AS 'Modalidad',
TD_NMONPER AS 'Imp.Percep.',
ISNULL(CAST(TD_DFECRECEP AS VARCHAR),'') AS 'Fecha Recep.'
from CC0005TRAD AS TRAD
INNER JOIN CC0005CART AS CARTERA
ON TRAD.TD_CNRODOC = CARTERA.CD_CNRODOC
where TD_CESTADO <> 'A' AND TD_CNUMTRA = '037928'

select TG_CDESCRI as 'TipoPago',RP_CTIPMON as 'Mon', sum(case when RP_CTIPMON = 'MN'


THEN RP_NIMPTMN ELSE RP_NIMPTUS END) AS 'Importe MN',
CONVERT(DECIMAL(19,2),sum(case when RP_CTIPMON = 'MN' THEN (RP_NIMPTMN / RP_NTIPCAM)
ELSE (RP_NIMPTUS * RP_NTIPCAM) END)) AS 'Importe US'
from CC0005FORP as forp
inner join AL0005TABL as tabla
on forp.RP_CFORPAG = tabla.TG_CCLAVE
inner join FT0005CLIE as clie
on forp.RP_CCODCLI = clie.CL_CCODCLI
where RP_CNROLIQ = '00000254578' AND TG_CCOD = '52'
group by TG_CDESCRI,RP_CTIPMON
TE MUESTRA LOS PRIMEROS Y LOS ULTIMOS

SELECT * FROM (select top(50) cl_ccodcli as 'Codigo',cl_cnomcli as 'Nombre' from


ft0005clie order by cl_cnomcli ASC) X
UNION
SELECT * FROM (select top(50) cl_ccodcli as 'Codigo',cl_cnomcli as
'Nombre' from ft0005clie order by cl_cnomcli DESC) X
ORDER BY 2 ASC