|
|
|
3 запроса для студента
|
|||
|---|---|---|---|
|
#18+
Господа не проходите мимо помогите студенту чем можете!!! Скрипт создания БД (Магазин): Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. Требуется написать следующие запросы (Или хоть один из них): 1)Для всех стран, которые производят более 1-го типа тов-ов, выдать max-ную стоимость какого-либо товара. 2)Напечатать кассы содержащие не менее 5-ти товаров, которые были проданы из страны 'X' за последние 3 дня. 3)Для каждой страны вывести общее кол-во товаров проданных за последние 3 дня, не менее 2-х единиц и отсортировать по названию товара. P.S. Написать всё надо на чистом SQL без применения всяких курсоров и т.д. Большая просьба помочь. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 26.04.2003, 00:11 |
|
||
|
3 запроса для студента
|
|||
|---|---|---|---|
|
#18+
Hi! Na 1:: SQL> alter table COUNTRY 2 add constraint pk_country_id primary key (ID_COUNTRY); Table altered Executed in 0.141 seconds SQL> alter table COUNTRY 2 add constraint uk_country_name unique (COUNTRYNAME); Table altered Executed in 0.062 seconds SQL> SQL> SQL> -- Create/Recreate primary, unique and foreign key constraints SQL> alter table GOODSNAME 2 add constraint pk_goods_id primary key (ID_GOODSNAME); Table altered Executed in 0.047 seconds SQL> SQL> SQL> -- Create/Recreate primary, unique and foreign key constraints SQL> alter table GOODS 2 add constraint fk_goods_country foreign key (ID_COUNTRY) 3 references country (ID_COUNTRY); Table altered Executed in 0.047 seconds SQL> alter table GOODS 2 add constraint fk_goods_id foreign key (ID_GOODS) 3 references goodsname (ID_GOODSNAME); Table altered Executed in 0.047 seconds SQL> SQL> -- Create/Recreate primary, unique and foreign key constraints SQL> alter table GOODS 2 add constraint pk_goods primary key (ID_GOODS); Table altered Executed in 0.078 seconds SQL> -- Create/Recreate indexes SQL> create index goods$goodsname on GOODS (ID_GOODSNAME); Index created Executed in 0.031 seconds SQL> create index goods$firm on GOODS (ID_FIRM); Index created Executed in 0.046 seconds SQL> create index goods$country on GOODS (ID_COUNTRY); Index created Executed in 0.093 seconds SQL> SQL> select countryname, goodsname, price 2 from 3 (Select a.countryname, c.goodsname, b.price, 4 MAX(b.price) OVER (Partition by b.id_country) AS max_price 5 From country a, goods b, goodsname c 6 where a.id_country = b.id_country 7 and c.id_goodsname = b.id_goodsname) 8 where price = max_price 9 / COUNTRYNAME GOODSNAME PRICE -------------------------------------------------- -------------------------------------------------- --------------------------------------- Executed in 0.047 seconds ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.04.2003, 09:25 |
|
||
|
3 запроса для студента
|
|||
|---|---|---|---|
|
#18+
Na 2:: Select a.cashname, d.countryname, COUNT(c.id_goods) counter From CASH a, Orders b, Goods c, Country D Where a.id_cash = b.id_cash and d.id_country = c.id_country and trunc(datetime) >= Trunc( sysdate - 3) Group by a.cashname, d.countryname Having COUNT(c.id_goods) >= 5 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.04.2003, 10:37 |
|
||
|
3 запроса для студента
|
|||
|---|---|---|---|
|
#18+
Na 3:: SELECT DECODE(GROUPING(a.countryname), 1, 'All Countries', a.countryname) AS Country, DECODE(GROUPING(b.cashname), 1, 'All Cash', b.cashname) AS Cash, DECODE(GROUPING(e.id_goodsname), 1, 'All Goodsname', e.id_goodsname) AS goods_name, TO_CHAR(SUM(c.amount), '9,999,999,999') SALES$ FROM Country A, Cash B, Orders C, Goods D, Goodsname E WHERE a.id_country = d.id_country and b.id_cash = c.id_cash and e.id_goodsname = d.id_goodsname and c.id_goods = d.id_goods and trunc(c.datetime) > trunc(sysdate - 3) GROUP BY CUBE(a.countryname,b.cashname, e.id_goodsname) Having (Count(e.id_goodsname) > 2); ========== Kagetsya, tak.... Narod proverit ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.04.2003, 10:52 |
|
||
|
|

start [/forum/topic.php?fid=52&fpage=2784&tid=1990780]: |
0ms |
get settings: |
7ms |
get forum list: |
15ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
46ms |
get topic data: |
9ms |
get forum data: |
2ms |
get page messages: |
28ms |
get tp. blocked users: |
1ms |
| others: | 233ms |
| total: | 345ms |

| 0 / 0 |
