Your SlideShare is downloading. ×
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
C ampos calculados ramiro
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

C ampos calculados ramiro

55

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
55
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 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
  • 2. BASE DE DATOSSELECT NOM_PER,FECHA_PER FROM PERSONAL WHERE FECHA_PER=20/12/2000RAMIRO CUSILAYME AGUILAR
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. BASE DE DATOSCalculamos un campo calculado:select stock_pro,costo_pro,stock_pro*costo_pro as valor_total fromarticuloRAMIRO CUSILAYME AGUILAR
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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

×