diff --git a/Semester 2/SQL Hell b/Semester 2/SQL Hell new file mode 100644 index 0000000..f179139 --- /dev/null +++ b/Semester 2/SQL Hell @@ -0,0 +1,21 @@ +/* select the snumbers and the number of parts suppled and the average qty of parts supplied for those suppliers who have a qty greater than the average qty of all suppliers. */ +select avg(qty) +from spj +group by snumber; + +#/ average of parts supplied */ +select avg(qty) +from spj; + +/* select the snumbers and the number of parts suppled and the average qty of parts supplied for those suppliers who have a qty greater than the average qty of all suppliers. */ +select snumber, avg(qty) +from spj +group by snumber +having avg(qty) > ( + + (select avg(qty) from spj)); + + + + +/* select number and the avg qty for suppliers whos range is greater tham the sum of all qty */ diff --git a/Semester 2/SQL Hell.txt b/Semester 2/SQL Hell.txt new file mode 100644 index 0000000..0b27d51 --- /dev/null +++ b/Semester 2/SQL Hell.txt @@ -0,0 +1,49 @@ +/* select the snumbers and the number of parts suppled and the average qty of parts supplied for those suppliers who have a qty greater than the average qty of all suppliers. */ +select avg(qty) +from spj +group by snumber; + +#/ average of parts supplied */ +select avg(qty) +from spj; + +/* select the snumbers and the number of parts suppled and the average qty of parts supplied for those suppliers who have a qty greater than the average qty of all suppliers. */ +select snumber, avg(qty) +from spj +group by snumber +having avg(qty) > ( + + (select avg(qty) from spj)); + + + + + +/* select number and the avg qty for suppliers whose range is greater tham the sum of all qty */ +select snumber, avg(qty), (select avg(qty) as AVERAGE_QTY_OF_ALL) +from spj +group by snumber +having avg(qty) > + (select avg(qty) + from spj); + +/* list snumber, snames, and total number of parts supplied for suppliers who live in london, athens or paris, Use nested selects. +1. Use WHERE clause only without nested selects. +2. Use nested selects . +*/ + +select supplier.snumber, sname, pnumber, city +from supplier, spj +where supplier.snumber = spj.snumber and +(city = 'paris' or city = 'london'); + +select supplier.snumber, sname, count(pnumber) as NUM_PARTS_SUPPLIED +from supplier, spj +where supplier.snumber = spj.snumber and +(city = 'paris' or city = 'london') +group by spj.snumber; + +select supplier.snumber, count(pnumber) as NUM_PARTS_SUPPLIED +(select sname from supplier where snumber = spj.snumber) +(select city from supplier where snumber = spj.snumber) +from spj diff --git a/lamp/mysql/#ib_16384_0.dblwr b/lamp/mysql/#ib_16384_0.dblwr index cce9a29..402d761 100755 Binary files a/lamp/mysql/#ib_16384_0.dblwr and b/lamp/mysql/#ib_16384_0.dblwr differ diff --git a/lamp/mysql/#innodb_temp/temp_1.ibt b/lamp/mysql/#innodb_temp/temp_1.ibt index 82eab3c..cb72483 100644 Binary files a/lamp/mysql/#innodb_temp/temp_1.ibt and b/lamp/mysql/#innodb_temp/temp_1.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_10.ibt b/lamp/mysql/#innodb_temp/temp_10.ibt index eb85196..a062902 100644 Binary files a/lamp/mysql/#innodb_temp/temp_10.ibt and b/lamp/mysql/#innodb_temp/temp_10.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_2.ibt b/lamp/mysql/#innodb_temp/temp_2.ibt index 7b68fc6..c76ab62 100644 Binary files a/lamp/mysql/#innodb_temp/temp_2.ibt and b/lamp/mysql/#innodb_temp/temp_2.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_3.ibt b/lamp/mysql/#innodb_temp/temp_3.ibt index d933ad4..7ec4853 100644 Binary files a/lamp/mysql/#innodb_temp/temp_3.ibt and b/lamp/mysql/#innodb_temp/temp_3.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_4.ibt b/lamp/mysql/#innodb_temp/temp_4.ibt index 4a0adb9..f9c81df 100644 Binary files a/lamp/mysql/#innodb_temp/temp_4.ibt and b/lamp/mysql/#innodb_temp/temp_4.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_5.ibt b/lamp/mysql/#innodb_temp/temp_5.ibt index 2a29040..3780ae7 100644 Binary files a/lamp/mysql/#innodb_temp/temp_5.ibt and b/lamp/mysql/#innodb_temp/temp_5.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_6.ibt b/lamp/mysql/#innodb_temp/temp_6.ibt index 03aa394..f2662b9 100644 Binary files a/lamp/mysql/#innodb_temp/temp_6.ibt and b/lamp/mysql/#innodb_temp/temp_6.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_7.ibt b/lamp/mysql/#innodb_temp/temp_7.ibt index f780572..fd5ab3e 100644 Binary files a/lamp/mysql/#innodb_temp/temp_7.ibt and b/lamp/mysql/#innodb_temp/temp_7.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_8.ibt b/lamp/mysql/#innodb_temp/temp_8.ibt index 378a937..bf9b973 100644 Binary files a/lamp/mysql/#innodb_temp/temp_8.ibt and b/lamp/mysql/#innodb_temp/temp_8.ibt differ diff --git a/lamp/mysql/#innodb_temp/temp_9.ibt b/lamp/mysql/#innodb_temp/temp_9.ibt index 76a7c00..a2579e3 100644 Binary files a/lamp/mysql/#innodb_temp/temp_9.ibt and b/lamp/mysql/#innodb_temp/temp_9.ibt differ diff --git a/lamp/mysql/565094360db9.pid b/lamp/mysql/565094360db9.pid old mode 100644 new mode 100755 diff --git a/lamp/mysql/87c780094856.pid b/lamp/mysql/87c780094856.pid new file mode 100644 index 0000000..730a054 --- /dev/null +++ b/lamp/mysql/87c780094856.pid @@ -0,0 +1 @@ +172 diff --git a/lamp/mysql/binlog.000030 b/lamp/mysql/binlog.000030 old mode 100644 new mode 100755 index 1e09c25..3cf3c2c Binary files a/lamp/mysql/binlog.000030 and b/lamp/mysql/binlog.000030 differ diff --git a/lamp/mysql/binlog.000031 b/lamp/mysql/binlog.000031 new file mode 100644 index 0000000..685ca2d Binary files /dev/null and b/lamp/mysql/binlog.000031 differ diff --git a/lamp/mysql/binlog.index b/lamp/mysql/binlog.index index 34a87be..b109584 100644 --- a/lamp/mysql/binlog.index +++ b/lamp/mysql/binlog.index @@ -27,3 +27,4 @@ ./binlog.000028 ./binlog.000029 ./binlog.000030 +./binlog.000031 diff --git a/lamp/mysql/ib_logfile0 b/lamp/mysql/ib_logfile0 index b136a02..56d9666 100755 Binary files a/lamp/mysql/ib_logfile0 and b/lamp/mysql/ib_logfile0 differ diff --git a/lamp/mysql/ibdata1 b/lamp/mysql/ibdata1 index e1d7972..4e9c92b 100755 Binary files a/lamp/mysql/ibdata1 and b/lamp/mysql/ibdata1 differ diff --git a/lamp/mysql/ibtmp1 b/lamp/mysql/ibtmp1 index 1da7556..c8ab5af 100644 Binary files a/lamp/mysql/ibtmp1 and b/lamp/mysql/ibtmp1 differ diff --git a/lamp/mysql/mysql.ibd b/lamp/mysql/mysql.ibd index c15df66..9daa115 100755 Binary files a/lamp/mysql/mysql.ibd and b/lamp/mysql/mysql.ibd differ diff --git a/lamp/mysql/phpmyadmin/pma__recent.ibd b/lamp/mysql/phpmyadmin/pma__recent.ibd index 714cb4e..e30b42f 100755 Binary files a/lamp/mysql/phpmyadmin/pma__recent.ibd and b/lamp/mysql/phpmyadmin/pma__recent.ibd differ diff --git a/lamp/mysql/phpmyadmin/pma__userconfig.ibd b/lamp/mysql/phpmyadmin/pma__userconfig.ibd index 124db6a..633156d 100755 Binary files a/lamp/mysql/phpmyadmin/pma__userconfig.ibd and b/lamp/mysql/phpmyadmin/pma__userconfig.ibd differ diff --git a/lamp/mysql/tennis_db/matches.ibd b/lamp/mysql/tennis_db/matches.ibd old mode 100644 new mode 100755 diff --git a/lamp/mysql/tennis_db/players.ibd b/lamp/mysql/tennis_db/players.ibd old mode 100644 new mode 100755 diff --git a/lamp/mysql/tennis_db/teams.ibd b/lamp/mysql/tennis_db/teams.ibd old mode 100644 new mode 100755 diff --git a/lamp/mysql/undo_001 b/lamp/mysql/undo_001 index 344cd01..82bc2e5 100755 Binary files a/lamp/mysql/undo_001 and b/lamp/mysql/undo_001 differ diff --git a/lamp/mysql/undo_002 b/lamp/mysql/undo_002 index fad8d7d..052b173 100755 Binary files a/lamp/mysql/undo_002 and b/lamp/mysql/undo_002 differ