NellyIvanova29

Изпитване 18.11.2021

Nov 18th, 2021 (edited)
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 6.45 KB | None | 0 0
  1. Setting environment for using XAMPP for Windows.
  2. nelly@NELLYIVANOVA c:\xampp
  3. # mysql -uroot
  4. Welcome to the MariaDB monitor.  Commands end with ; or \g.
  5. Your MariaDB connection id is 19
  6. Server version: 10.4.21-MariaDB mariadb.org binary distribution
  7.  
  8. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  9.  
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11.  
  12. MariaDB [(none)]> create database company;
  13. Query OK, 1 row affected (0.017 sec)
  14.  
  15. MariaDB [(none)]> use company;
  16. Database changed
  17. MariaDB [company]> create table company(
  18.     -> name VARCHAR (50) NOT NULL,
  19.     -> position VARCHAR (50) NOT NULL,
  20.     -> year INT,
  21.     -> age INT,
  22.     -> salary FLOAT);
  23. Query OK, 0 rows affected (0.065 sec)
  24.  
  25. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Ralitsa Marinova','CEO','2015','45','8000');
  26. Query OK, 1 row affected (0.026 sec)
  27.  
  28. MariaDB [company]> select* from company;
  29. +------------------+----------+------+------+--------+
  30. | name             | position | year | age  | salary |
  31. +------------------+----------+------+------+--------+
  32. | Ralitsa Marinova | CEO      | 2015 |   45 |   8000 |
  33. +------------------+----------+------+------+--------+
  34. 1 row in set (0.012 sec)
  35.  
  36. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Galia Ivanova','senior programmer','2018','45','6000');
  37. Query OK, 1 row affected (0.002 sec)
  38.  
  39. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Milena Georgieva','junior programmer','2020','23','4000');
  40. Query OK, 1 row affected (0.008 sec)
  41.  
  42. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Kristina Petkova','junior programmer','2020','24','4000');
  43. Query OK, 1 row affected (0.008 sec)
  44.  
  45. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Nadia Ivanova','Online Business Manager','2020','22','3000');
  46. Query OK, 1 row affected (0.002 sec)
  47.  
  48. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Georgi Hristov','senior programmer','2017','28','6500');
  49. Query OK, 1 row affected (0.008 sec)
  50.  
  51. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Gabriel Yankov','designer','2017','28','5000');
  52. Query OK, 1 row affected (0.003 sec)
  53.  
  54. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Daniel Dimitrov','designer','2018','26','5500');
  55. Query OK, 1 row affected (0.002 sec)
  56.  
  57. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Samuil Georgiev','QA','2019','26','4000');
  58. Query OK, 1 row affected (0.007 sec)
  59.  
  60. MariaDB [company]> INSERT INTO company (name, position, year, age, salary) VALUES('Ivana Karaivanova','QA','2019','24','3800');
  61. Query OK, 1 row affected (0.007 sec)
  62.  
  63. MariaDB [company]> select* from company;
  64. +-------------------+-------------------------+------+------+--------+
  65. | name              | position                | year | age  | salary |
  66. +-------------------+-------------------------+------+------+--------+
  67. | Ralitsa Marinova  | CEO                     | 2015 |   45 |   8000 |
  68. | Galia Ivanova     | senior programmer       | 2018 |   45 |   6000 |
  69. | Milena Georgieva  | junior programmer       | 2020 |   23 |   4000 |
  70. | Kristina Petkova  | junior programmer       | 2020 |   24 |   4000 |
  71. | Nadia Ivanova     | Online Business Manager | 2020 |   22 |   3000 |
  72. | Georgi Hristov    | senior programmer       | 2017 |   28 |   6500 |
  73. | Gabriel Yankov    | designer                | 2017 |   28 |   5000 |
  74. | Daniel Dimitrov   | designer                | 2018 |   26 |   5500 |
  75. | Samuil Georgiev   | QA                      | 2019 |   26 |   4000 |
  76. | Ivana Karaivanova | QA                      | 2019 |   24 |   3800 |
  77. +-------------------+-------------------------+------+------+--------+
  78. 10 rows in set (0.007 sec)
  79.  
  80. MariaDB [company]> select * from company ORDER BY salary DESC;
  81. +-------------------+-------------------------+------+------+--------+
  82. | name              | position                | year | age  | salary |
  83. +-------------------+-------------------------+------+------+--------+
  84. | Ralitsa Marinova  | CEO                     | 2015 |   45 |   8000 |
  85. | Georgi Hristov    | senior programmer       | 2017 |   28 |   6500 |
  86. | Galia Ivanova     | senior programmer       | 2018 |   45 |   6000 |
  87. | Daniel Dimitrov   | designer                | 2018 |   26 |   5500 |
  88. | Gabriel Yankov    | designer                | 2017 |   28 |   5000 |
  89. | Milena Georgieva  | junior programmer       | 2020 |   23 |   4000 |
  90. | Kristina Petkova  | junior programmer       | 2020 |   24 |   4000 |
  91. | Samuil Georgiev   | QA                      | 2019 |   26 |   4000 |
  92. | Ivana Karaivanova | QA                      | 2019 |   24 |   3800 |
  93. | Nadia Ivanova     | Online Business Manager | 2020 |   22 |   3000 |
  94. +-------------------+-------------------------+------+------+--------+
  95. 10 rows in set (0.009 sec)
  96.  
  97. MariaDB [company]> SELECT MIN(age) from company;
  98. +----------+
  99. | MIN(age) |
  100. +----------+
  101. |       22 |
  102. +----------+
  103. 1 row in set (0.001 sec)
  104.  
  105. MariaDB [company]> select* from company where position='Online Business Manager'and name='Nadia Ivanova';
  106. +---------------+-------------------------+------+------+--------+
  107. | name          | position                | year | age  | salary |
  108. +---------------+-------------------------+------+------+--------+
  109. | Nadia Ivanova | Online Business Manager | 2020 |   22 |   3000 |
  110. +---------------+-------------------------+------+------+--------+
  111. 1 row in set (0.001 sec)
  112.  
  113. MariaDB [company]> Select position,AVG(salary) as "average salary" from company Group by position;
  114. +-------------------------+----------------+
  115. | position                | average salary |
  116. +-------------------------+----------------+
  117. | CEO                     |           8000 |
  118. | designer                |           5250 |
  119. | junior programmer       |           4000 |
  120. | Online Business Manager |           3000 |
  121. | QA                      |           3900 |
  122. | senior programmer       |           6250 |
  123. +-------------------------+----------------+
  124. 6 rows in set (0.003 sec)
  125.  
  126. MariaDB [company]> Select year,COUNT(year) as "count" from company Group by year;
  127. +------+------------+
  128. | year |    count   |
  129. +------+------------+
  130. | 2015 |          1 |
  131. | 2017 |          2 |
  132. | 2018 |          2 |
  133. | 2019 |          2 |
  134. | 2020 |          3 |
  135. +------+------------+
  136. 5 rows in set (0.001 sec)
  137.  
  138. MariaDB [company]>
Add Comment
Please, Sign In to add comment