Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. /*create database evidenta;
  2. use evidenta;
  3. create table produse
  4. (
  5. Producator char(1) not null,
  6. Model varchar(4) not null,
  7. Tip varchar(10) not null
  8.  
  9. );
  10.  
  11. create table pc_uri
  12. (
  13. Cod int not null,
  14. Model varchar(4) not null,
  15. Viteza decimal(3,0) not null,
  16. Ram decimal(3,0) not null,
  17. Hd decimal(2,0) not null,
  18. Cd varchar (3) not null,
  19. Pret float not null
  20.  
  21.  
  22. );
  23.  
  24. create table laptop_uri
  25. (
  26. Cod int not null,
  27. Model varchar(4) not null,
  28. Viteza decimal(3,0) not null,
  29. Ram decimal(3,0) not null,
  30. Hd decimal(2,0) not null,
  31. Pret float not null,
  32. Ecran int not null
  33.  
  34. );
  35.  
  36.  
  37. create table imprimante
  38. (
  39. Cod int not null,
  40. Model varchar(4) not null,
  41. Color char(2) not null,
  42. Tip varchar(6) not null,
  43. Pret float not null
  44.  
  45. );
  46.  
  47. insert into produse values ('B', 1121, 'PC');
  48. insert into produse values ('A', 1232, 'PC');
  49. insert into produse values ('B', 1233, 'PC');
  50. insert into produse values ('E', 1260, 'PC');
  51. insert into produse values ('A', 1276, 'Imprimante');
  52. insert into produse values ('D', 1288, 'Imprimante');
  53. insert into produse values ('A', 1298, 'Laptop_uri');
  54. insert into produse values ('C', 1321, 'Laptop_uri');
  55. insert into produse values ('A', 1401, 'Imprimante');
  56. insert into produse values ('A', 1408, 'Imprimante');
  57. insert into produse values ('D', 1433, 'Imprimante');
  58. insert into produse values ('E', 1434, 'Imprimante');
  59. insert into produse values ('B', 1750, 'Laptop_uri');
  60. insert into produse values ('A', 1752, 'Laptop_uri');
  61. insert into produse values ('E', 2111, 'PC');
  62. insert into produse values ('E', 2112, 'PC');
  63.  
  64. insert into imprimante values (1 , '1276' , 'nu' , 'Laser' , 400);
  65. insert into imprimante values (2 , '1433' , 'da' , 'Jet' , 270);
  66. insert into imprimante values (3 , '1434' , 'da' , 'Jet' , 290);
  67. insert into imprimante values (4 , '1401' , 'nu' , 'Matrix' , 150);
  68. insert into imprimante values (5 , '1408' , 'nu' , 'Matrix' , 270);
  69. insert into imprimante values (6 , '1288' , 'nu' , 'Laser' , 400);
  70.  
  71. INSERT INTO pc_uri VALUES ( 1, 1232, 500, 64 , 5, '12x', 600 ), ( 2, 1121, 750, 128, 14, '40x', 850 ),
  72. ( 3 , 1233, 500, 64, 5, '12x', 600 ), ( 4, 1121, 600, 128, 14, '40x', 850 ), ( 5, 1121, 600, 128, 8, '40x', 850 ),
  73. ( 6, 1233, 750, 128, 20, '50x', 950 ), ( 7, 1232, 500, 32, 10, '12x', 400 ), ( 8, 1232, 450, 64, 8, '24x', 350 ),
  74. ( 9, 1232, 450, 32, 10, '24x', 350 ), ( 10, 1260, 500, 32, 10, '12x', 350 ), ( 11, 1233, 900, 128, 40, '40x', 980 );
  75.  
  76. insert into laptop_uri values (1,1298,350,32,4,700,11),(2,1231,500,64,8,970,12),(3,1750,750,128,12,1200,14),(4,1298,600,64,10,1050,15),(5,1752,750,128,10,1150,14),(6,1298,450,64,10,950,120);*/
  77.  
  78. select producator
  79. from pc_uri inner join produse on pc_uri.model = produse.model
  80. where viteza > 450 group by producator;
  81.  
  82. select Model , Pret
  83. from imprimante where Pret = (select max(Pret) FROM Imprimante);
  84.  
  85. select avg(Viteza)
  86. from pc_uri;
  87.  
  88. select avg()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement