C ampos calculados ramiro
Upcoming SlideShare
Loading in...5
×
 

C ampos calculados ramiro

on

  • 190 views

 

Statistics

Views

Total Views
190
Views on SlideShare
185
Embed Views
5

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 5

http://ultraram.blogspot.com 5

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

C ampos calculados ramiro C ampos calculados ramiro Document Transcript

  • BASE DE DATOSCAMPOS CALCULADOS CON FECHACREATE DATABASE ALUMNOSUSE ALUMNOSCREATE TABLE PERSONAL(COD_PER NVARCHAR (20) NOT NULL,NOM_PER NVARCHAR (50) NOT NULL,SEMESTRE_PER NVARCHAR (50)NOT NULL,CARRERA_PER NVARCHAR (50)NOT NULL,FECHA_PER smalldatetime NOT NULL)insert into PERSONAL(COD_PER,NOM_PER,SEMESTRE_PER,CARRERA_PER,FECHA_PER)values(001,MENDOZA ARLISS,IV,COMPUTACION,12/09/1970)insert into PERSONAL(COD_PER,NOM_PER,SEMESTRE_PER,CARRERA_PER,FECHA_PER)values(002,CONTRERAS MIGUEL,II,ADMINISTRACION,12/10/1991)insert into PERSONAL(COD_PER,NOM_PER,SEMESTRE_PER,CARRERA_PER,FECHA_PER)values(003,PAREDES JOSE,IV,COMPUTACION,5/08/1990)insert into PERSONAL(COD_PER,NOM_PER,SEMESTRE_PER,CARRERA_PER,FECHA_PER)values(004,ZEGARRA CARINA,II,ADMINISTRACION,20/12/2000)SELECT NOM_PER,FECHA_PER,YEAR(GETDATE())-YEAR (FECHA_PER) AS EDAD FROMPERSONALSELECT NOM_PER,STR(YEAR(GETDATE())-YEAR(FECHA_PER))+AÑOS AS EDAD FROMPERSONALRAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSSELECT NOM_PER,FECHA_PER FROM PERSONAL WHERE FECHA_PER=20/12/2000RAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSSELECT NOM_PER,FECHA_PER FROM PERSONAL WHERE YEAR(FECHA_PER)=1990SELECT NOM_PER,FECHA_PER FROM PERSONAL WHERE MONTH(FECHA_PER)=12RAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSSELECT NOM_PER,FECHA_PER FROM PERSONAL WHERE DAY(FECHA_PER)=12 ANDMONTH(FECHA_PER)=9SELECT NOM_PER,FECHA_PER FROM PERSONAL WHERE MONTH(FECHA_PER)IN(20,12,2000)RAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSSELECT NOM_PER,FECHA_PER FROM PERSONAL WHERE MONTH(FECHA_PER)IN (12,5)Creamos base de datos tiendasCREATE DATABASE TiendaUSE Tiendacreate table articulo(cod_pro nvarchar(10)not null,nombre_pro nvarchar(20) not null,costo_pro numeric(18,0) not null,precio_pro numeric(18,0) not null,stock_pro smallint)select * from articuloRAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSCalculamos un campo calculado:select stock_pro,costo_pro,stock_pro*costo_pro as valor_total fromarticuloRAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSselect nombre_pro,costo_pro,precio_pro,stock_pro,costo_pro*stock_pro asvalorizado from articuloselect nombre_pro,costo_pro,precio_pro,stock_pro,costo_pro*stock_pro asSVP from articuloRAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSselect nombre_pro,costo_pro,precio_pro,stock_pro,(precio_pro-costo_pro)*stock_pro as UTILIDADES from articuloCAMPOS CALCULADOS CON VARIOS CAMPOS:select nombre_pro,costo_pro,precio_pro,stock_pro,costo_pro*stock_pro asSVC,precio_pro*stock_pro as SVP,(precio_pro-costo_pro)*stock_pro asUTILIDADES from articuloRAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSselect nombre_pro,precio_pro,(precio_pro*20)/100 AS DESCUENTO fromarticuloselect nombre_pro,precio_pro,precio_pro-(precio_pro*20)/100 AS PPUBLICOfrom articuloRAMIRO CUSILAYME AGUILAR
  • BASE DE DATOSselect nombre_pro,precio_pro,(precio_pro*20)/100 AS DESCUENTO,precio_pro-(precio_pro*20/100)AS PPUBLICO from articuloRAMIRO CUSILAYME AGUILAR