Advertisement
Jgug

Views (IOSY3)

Nov 16th, 2014
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 15.35 KB | None | 0 0
  1. CREATE OR REPLACE VIEW Name_1 AS
  2. SELECT *
  3. FROM StaffVSHKL;
  4.  
  5.  
  6.  
  7. /* View for offices in Vitebsk */
  8. CREATE OR REPLACE VIEW BranchesInVitebsk AS
  9. SELECT bno, street, tel_no
  10. FROM BranchVSHKL
  11. WHERE city = 'Vitebsk';
  12.  
  13. SELECT * FROM BranchesInVitebsk;
  14.  
  15.  
  16.  
  17. /* View for rent objects with minimal price */
  18. CREATE OR REPLACE VIEW MinimalPrice AS
  19. SELECT pno, street, city, TYPE, rooms, rent
  20. FROM PropertForRentVSHKL
  21.  
  22. SELECT
  23. MIN(
  24.     CASE
  25.     WHEN PropertyForRentVSHKL.TYPE = 'h'
  26.     THEN rent
  27.     ELSE NULL
  28.     END
  29.     ) AS Cheap_house,
  30. MIN(
  31.     CASE
  32.     WHEN PropertyForRentVSHKL.TYPE = 'f'
  33.     THEN rent
  34.     ELSE NULL
  35.     END
  36.     ) AS Cheap_flat
  37. FROM PropertyForRentVSHKL;
  38. /*
  39. CHEAP_HOUSE CHEAP_FLAT
  40. ----------- ----------
  41.         300        300
  42. */
  43.  
  44. SELECT pno, MIN(rent) AS Cheap_house
  45. FROM PropertyForRentVSHKL
  46. WHERE TYPE = 'h'
  47. GROUP BY pno;
  48.  
  49. SELECT P.TYPE AS TYPE, MIN(P.rent) AS PRICE
  50. FROM PropertyForRentVSHKL P
  51. WHERE P.TYPE = 'h'
  52. GROUP BY P.TYPE
  53. UNION
  54. SELECT P.TYPE AS TYPE, MIN(P.rent) AS PRICE
  55. FROM PropertyForRentVSHKL P
  56. WHERE P.TYPE = 'f'
  57. GROUP BY P.TYPE;
  58.  
  59. SELECT pno, MIN(rent) AS Cheap_house
  60. FROM PropertyForRentVSHKL
  61. WHERE TYPE = 'h'
  62. GROUP BY pno;
  63.  
  64. SELECT
  65. MIN(
  66.     CASE
  67.     WHEN PropertyForRentVSHKL.TYPE = 'h'
  68.     THEN rent
  69.     ELSE NULL
  70.     END
  71.     ) AS Rent
  72. FROM PropertyForRentVSHKL
  73. GROUP BY pno;
  74.  
  75. SELECT street, city
  76. MAX(
  77.     CASE
  78.     WHEN PropertyForRentVSHKL.TYPE = 'h'
  79.     THEN rent
  80.     ELSE NULL
  81.     END
  82.     ) AS Rent
  83. FROM PropertyForRentVSHKL
  84. UNION
  85. SELECT street, city,
  86. MAX(
  87.     CASE
  88.     WHEN PropertyForRentVSHKL.TYPE = 'f'
  89.     THEN rent
  90.     ELSE NULL
  91.     END
  92.     ) AS Rent
  93. FROM PropertyForRentVSHKL;
  94.  
  95. SELECT pno, TYPE, rent
  96. FROM PropertyForRentVSHKL
  97. WHERE TYPE = 'f';
  98.  
  99. CREATE OR REPLACE VIEW MinimalPrice AS
  100. SELECT *
  101. FROM(
  102.     SELECT *
  103.     FROM PropertyForRentVSHKL
  104.     WHERE (TYPE, rent) IN (
  105.         SELECT  TYPE, MIN(rent)
  106.         FROM PropertyForRentVSHKL
  107.         WHERE TYPE = 'h'
  108.         GROUP BY TYPE
  109.         )
  110.     UNION
  111.     SELECT *
  112.     FROM PropertyForRentVSHKL
  113.     WHERE (TYPE, rent) IN (
  114.         SELECT  TYPE, MIN(rent)
  115.         FROM PropertyForRentVSHKL
  116.         WHERE TYPE = 'f'
  117.         GROUP BY TYPE
  118.         )
  119.     );
  120.  
  121. SELECT * FROM MinimalPrice;
  122.  
  123.  
  124. /* View for number of views with comment */
  125. CREATE OR REPLACE VIEW NumberOfViewsWithComment AS
  126. SELECT COUNT(date1) AS Comments
  127. FROM ViewingVSHKL
  128. WHERE comment1 IS NOT NULL;
  129.  
  130. SELECT * FROM NumberOfViewsWithComment;
  131.  
  132. /*
  133.   COMMENTS
  134. ----------
  135.         18
  136. */
  137.  
  138. CREATE OR REPLACE VIEW NumberOfViewsWithoutComment AS
  139. SELECT COUNT(date1) AS Comments
  140. FROM ViewingVSHKL
  141. WHERE comment1 IS NULL;
  142.  
  143. SELECT * FROM NumberOfViewsWithoutComment;
  144.  
  145. /*
  146.   COMMENTS
  147. ----------
  148.          7
  149. */
  150.  
  151.  
  152. /* View for renters who want to get flat with 3 rooms */
  153. CREATE OR REPLACE VIEW RentersWhoWant3RoomFlat AS
  154.  
  155. -- Renters who want flat and can spend over 500 money
  156. CREATE OR REPLACE VIEW RentersWhoWantFlatOver500 AS
  157. SELECT *
  158. FROM RenterVSHKL
  159. WHERE pref_type = 'f' AND max_rent > 500;
  160.  
  161. SELECT * FROM RentersWhoWantFlatOver500;
  162.  
  163. -- Renters who want to rent flat with 3 rooms
  164. SELECT DISTINCT p.rooms, v.rno
  165. FROM PropertyForRentVSHKL p, ViewingVSHKL v
  166. WHERE p.pno = v.pno AND p.rooms = 3;
  167.  
  168. SELECT pno
  169. FROM PropertyForRentVSHKL
  170. WHERE rooms = 3;
  171. /*     PNO
  172. ----------
  173.       4332
  174.       4346
  175.       4360
  176.       4388
  177.       4395
  178.       4437*/
  179.  
  180. SELECT DISTINCT v.rno
  181. FROM ViewingVSHKL v, PropertyForRentVSHKL p
  182. WHERE v.pno IN (
  183.     SELECT pno
  184.     FROM PropertyForRentVSHKL
  185.     WHERE rooms = 3
  186.     );
  187. /*     RNO
  188. ----------
  189.       5325
  190.       5332
  191.       5381
  192.       5360
  193.       5353
  194.       5374*/
  195.  
  196. SELECT DISTINCT r.fname, r.lname, r.tel_no
  197. FROM ViewingVSHKL v, RenterVSHKL r
  198. WHERE v.pno IN (
  199.     SELECT pno
  200.     FROM PropertyForRentVSHKL
  201.     WHERE rooms = 3
  202.     ) AND v.rno = r.rno;      
  203. /*FNAME                  LNAME                    TEL_NO
  204. ------------------------ ------------------------ ------------
  205. Farah                    Martinez                 375292544448
  206. Rebecca                  Rogers                   375296601048
  207. Ronald                   Brooks                   375296621408
  208. Carol                    Richardson               375296621558
  209. Eugene                   Miller                   375296651008
  210. Shirley                  Morris                   375296012448*/
  211.  
  212. CREATE OR REPLACE VIEW RentersWhoWantFlatWith3Rooms AS
  213. SELECT DISTINCT r.fname, r.lname, r.tel_no
  214. FROM ViewingVSHKL v, RenterVSHKL r
  215. WHERE v.pno IN (
  216.     SELECT pno
  217.     FROM PropertyForRentVSHKL
  218.     WHERE rooms = 3
  219.     ) AND v.rno = r.rno;
  220.  
  221. SELECT * FROM RentersWhoWantFlatWith3Rooms;
  222.  
  223.  
  224. /* View for info about branch with max number of personnel */
  225. CREATE OR REPLACE VIEW BranchWithMaxPersonnel AS
  226.  
  227. SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  228. FROM StaffVSHKL
  229. GROUP BY bno
  230. ORDER BY Personnel DESC;
  231. /*
  232.   STAFFBNO  PERSONNEL
  233. ---------- ----------
  234.       1332          4
  235.       1325          4
  236.       1367          4
  237.       1346          4
  238.       1374          3
  239.       1360          3
  240.       1339          3
  241.       1353          2
  242. */
  243.  
  244. SELECT *
  245. FROM (
  246.     SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  247.     FROM StaffVSHKL
  248.     GROUP BY bno
  249.     )
  250. WHERE Personnel = (
  251.     SELECT MAX(Personnel)
  252.         FROM
  253.         (
  254.             SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  255.             FROM StaffVSHKL
  256.             GROUP BY bno
  257.         )
  258.     );
  259. /*
  260.   STAFFBNO  PERSONNEL
  261. ---------- ----------
  262.       1332          4
  263.       1346          4
  264.       1325          4
  265.       1367          4
  266. */
  267.  
  268. SELECT StaffBNO
  269. FROM (
  270.     SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  271.     FROM StaffVSHKL
  272.     GROUP BY bno
  273.     )
  274. WHERE Personnel = (
  275.     SELECT MAX(Personnel)
  276.         FROM
  277.         (
  278.             SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  279.             FROM StaffVSHKL
  280.             GROUP BY bno
  281.         )
  282.     )
  283. JOIN
  284. BranchVSHKL
  285. ON BranchVSHKL.bno = B.StaffBNO;
  286.  
  287. CREATE OR REPLACE VIEW BranchWithMaxPersonnel AS
  288. SELECT A.*, B.bno, B.street, B.city, B.tel_no
  289. FROM BranchVSHKL B, (
  290.     SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  291.     FROM StaffVSHKL
  292.     GROUP BY bno
  293.     ) A
  294. WHERE Personnel = (
  295.     SELECT MAX(Personnel)
  296.         FROM
  297.         (
  298.             SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  299.             FROM StaffVSHKL
  300.             GROUP BY bno
  301.         )
  302.     ) AND StaffBNO = B.bno;
  303.  
  304. CREATE OR REPLACE VIEW BranchWithMaxPersonnel AS
  305. SELECT BNO, city, street, tel_no
  306. FROM(
  307.     SELECT A.*, B.bno, B.street, B.city, B.tel_no
  308.     FROM BranchVSHKL B, (
  309.         SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  310.         FROM StaffVSHKL
  311.         GROUP BY bno
  312.         ) A
  313.     WHERE Personnel = (
  314.         SELECT MAX(Personnel)
  315.             FROM
  316.             (
  317.                 SELECT bno AS StaffBNO, COUNT(sno) AS Personnel
  318.                 FROM StaffVSHKL
  319.                 GROUP BY bno
  320.             )
  321.         ) AND StaffBNO = B.bno
  322.     );
  323. /*
  324. BNO   CITY     STREET        TEL_NO
  325. ----- -------- ------------- ------------
  326. 1332  Minsk    Kabushkina    375296954454
  327. 1325  Minsk    Timiryazeva   375296545454
  328. 1346  Minsk    Pritytskogo   375296651754
  329. 1367  Grodno   Kirova        375296541004
  330. */
  331.  
  332.  
  333. /* View for staff and objects they represent */
  334. CREATE OR REPLACE VIEW StaffAndRent AS
  335. SELECT S.sno, S.fname, S.lname, S.tel_no, S.bno,
  336.        P.pno, P.street, P.city, P.TYPE, P.rooms, P.rent
  337. FROM StaffVSHKL S, PropertyForRentVSHKL P
  338. WHERE S.sno = P.sno;
  339.  
  340. SELECT * FROM StaffAndRent;
  341.  
  342.  
  343. /* View for info about owners whose houses or flats
  344.  * was viewed
  345.  */
  346. CREATE OR REPLACE VIEW OwnersViewed AS
  347.  
  348. SELECT O.ono, O.fname, O.lname, O.address, O.tel_no,
  349.        P.pno, P.ono,
  350.        V.pno
  351. FROM OwnerVSHKL O, PropertyForRentVSHKL P, ViewingVSHKL V
  352. WHERE O.ono = P.ono AND V.pno = P.pno;
  353.  
  354. SELECT DISTINCT fname, lname, address, tel_no
  355. FROM(
  356.     SELECT O.ono, O.fname, O.lname, O.address, O.tel_no,
  357.            P.pno, P.ono,
  358.            V.pno
  359.     FROM OwnerVSHKL O, PropertyForRentVSHKL P, ViewingVSHKL V
  360.     WHERE O.ono = P.ono AND V.pno = P.pno
  361.     );
  362.  
  363.  
  364.  
  365. -- 5) redo
  366. SELECT DISTINCT bno
  367. FROM BranchVSHKL;
  368. /*
  369.        BNO
  370. ----------
  371.       1325
  372.       1332
  373.       1339
  374.       1346
  375.       1353
  376.       1360
  377.       1367
  378.       1374
  379. */
  380.  
  381. SELECT DISTINCT s.bno, s.sno
  382. FROM StaffVSHKL s;
  383. /*
  384.        BNO        SNO
  385. ---------- ----------
  386.       1325       2325
  387.       1325       2339
  388.       1325       2346
  389.       1325       2353
  390.  
  391.       1332       2367
  392.       1332       2374
  393.       1332       2381
  394.       1332       2388
  395.  
  396.       1339       2395
  397.       1339       2402
  398.       1339       2409
  399.  
  400.       1346       2416
  401.       1346       2423
  402.       1346       2430
  403.       1346       2444
  404.  
  405.       1353       2451
  406.       1353       2458
  407.  
  408.       1360       2465
  409.       1360       2479
  410.       1360       2486
  411.  
  412.       1367       2493
  413.       1367       2500
  414.       1367       2507
  415.       1367       2514
  416.  
  417.       1374       2521
  418.       1374       2528
  419.       1374       2535
  420. */
  421.  
  422. SELECT s.bno, COUNT(s.bno) COUNT_BNO
  423. FROM StaffVSHKL s
  424. GROUP BY s.bno;
  425. /*
  426.        BNO    COUNT_BNO
  427. ---------- ------------
  428.       1332            4
  429.       1353            2
  430.       1346            4
  431.       1325            4
  432.       1367            4
  433.       1339            3
  434.       1374            3
  435.       1360            3
  436. */
  437.  
  438. SELECT BNO, MAX(count_bno)
  439. FROM(
  440.     SELECT s.bno, COUNT(s.bno) COUNT_BNO
  441.     FROM StaffVSHKL s
  442.     GROUP BY s.bno
  443.     )
  444. GROUP BY BNO;
  445.  
  446. SELECT
  447. CASE
  448.     WHEN COUNT_BNO =
  449.     (
  450.         SELECT MAX(COUNT_BNO)
  451.         FROM(
  452.             SELECT s.bno, COUNT(s.bno) COUNT_BNO
  453.             FROM StaffVSHKL s
  454.             GROUP BY s.bno
  455.             )
  456.     )
  457.     THEN BNO
  458. END BNO_
  459. FROM(
  460.     SELECT s.bno, COUNT(s.bno) COUNT_BNO
  461.     FROM StaffVSHKL s
  462.     GROUP BY s.bno
  463.     );
  464.  
  465. -- SELECT b.city, b.street, b.tel_no
  466. -- FROM BranchVSHKL b
  467. -- HAVING MAX_BNO =
  468. --  (
  469. --      SELECT MAX(COUNT_BNO) MAX_BNO
  470. --      FROM(
  471. --          SELECT s.bno, COUNT(s.bno) COUNT_BNO
  472. --          FROM StaffVSHKL s
  473. --          GROUP BY s.bno
  474. --          )
  475. --  );
  476.  
  477. SELECT BNO
  478. FROM(
  479.     SELECT s.bno, COUNT(s.bno) COUNT_BNO
  480.     FROM StaffVSHKL s
  481.     GROUP BY s.bno
  482.     )
  483. WHERE COUNT_BNO =
  484.     (
  485.     SELECT MAX(COUNT_BNO)
  486.     FROM(
  487.         SELECT s.bno, COUNT(s.bno) COUNT_BNO
  488.         FROM StaffVSHKL s
  489.         GROUP BY s.bno
  490.         )
  491.     );
  492. --        BNO
  493. -- ----------
  494. --       1332
  495. --       1346
  496. --       1325
  497. --       1367
  498.  
  499. SELECT b.city, b.street, b.tel_no
  500. FROM BranchVSHKL b
  501. WHERE b.bno IN(
  502.     SELECT BNO
  503.     FROM(
  504.         SELECT s.bno, COUNT(s.bno) COUNT_BNO
  505.         FROM StaffVSHKL s
  506.         GROUP BY s.bno
  507.         )
  508.     WHERE COUNT_BNO =
  509.         (
  510.         SELECT MAX(COUNT_BNO)
  511.         FROM(
  512.             SELECT s.bno, COUNT(s.bno) COUNT_BNO
  513.             FROM StaffVSHKL s
  514.             GROUP BY s.bno
  515.             )
  516.         )  
  517.     );
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524. ---------------------------------------------------------------------
  525. ---------------------------------------------------------------------
  526. ---------------------------------------------------------------------
  527. ---------------------------------------------------------------------
  528. ---------------------------------------------------------------------
  529. ---------------------------------------------------------------------
  530. ---------------------------------------------------------------------
  531. ---------------------------------------------------------------------
  532. ---------------------------------------------------------------------
  533. ---------------------------------------------------------------------
  534.  
  535. -- 1) Информация об офисах в Витебске
  536. CREATE OR REPLACE VIEW BranchesInVitebsk AS
  537. SELECT bno, street, tel_no
  538. FROM BranchVSHKL
  539. WHERE city = 'Vitebsk';
  540.  
  541. SELECT * FROM BranchesInVitebsk;
  542.  
  543. /*  BNO    STREET           TEL_NO
  544.     ------------------------------------
  545.     1353   Leningradskaya   375296595644
  546.     1360   Gertsena         375296511024  */
  547.  
  548.  
  549.  
  550. -- 2) Информация об объектах недвижимости с минимальной стоимостью
  551. CREATE OR REPLACE VIEW MinimalPrice AS
  552.     SELECT *
  553.     FROM PropertyForRentVSHKL
  554.     WHERE (TYPE, rent) IN (
  555.         SELECT  TYPE, MIN(rent)
  556.         FROM PropertyForRentVSHKL
  557.         WHERE TYPE = 'h'
  558.         GROUP BY TYPE
  559.         )
  560.     UNION
  561.     SELECT *
  562.     FROM PropertyForRentVSHKL
  563.     WHERE (TYPE, rent) IN (
  564.         SELECT  TYPE, MIN(rent)
  565.         FROM PropertyForRentVSHKL
  566.         WHERE TYPE = 'f'
  567.         GROUP BY TYPE
  568.         );
  569.  
  570. SELECT * FROM MinimalPrice;
  571.  
  572. /*  PNO  STREET CITY     T  ROOMS   RENT    ONO    SNO   BNO
  573.     ---------------------------------------------------------
  574.     4402 Pravdi Vitebsk  f  2       300     3381   2500  1360
  575.     4416 Lenina Grodno   h  2       300     3395   2535  1367  */
  576.  
  577.  
  578.  
  579. -- 3) Информация о количестве сделанных осмотров с комментариями
  580. CREATE OR REPLACE VIEW NumberOfViewsWithComment AS
  581. SELECT COUNT(date1) AS NUMBER_OF_COMMENTS
  582. FROM ViewingVSHKL
  583. WHERE comment1 IS NOT NULL;
  584.  
  585. SELECT * FROM NumberOfViewsWithComment;
  586.  
  587. /*  COMMENTS
  588.     --------
  589.           18  */
  590.  
  591.  
  592.  
  593. -- 4) Информация об арендаторах желающих арендовать 3х комн. квартиру
  594. CREATE OR REPLACE VIEW RentersWhoWantFlatWith3Rooms AS
  595. SELECT DISTINCT r.fname RENTER_FIRSTNAME, r.lname RENTER_LASTNAME, r.tel_no RENTER_TEL_NO
  596. FROM ViewingVSHKL v, RenterVSHKL r
  597. WHERE v.pno IN (
  598.     SELECT pno
  599.     FROM PropertyForRentVSHKL
  600.     WHERE rooms = 3
  601.     ) AND v.rno = r.rno;
  602.  
  603. SELECT * FROM RentersWhoWantFlatWith3Rooms;
  604.  
  605. /*FNAME                  LNAME                    TEL_NO
  606. ------------------------ ------------------------ ------------
  607. Farah                    Martinez                 375292544448
  608. Rebecca                  Rogers                   375296601048
  609. Ronald                   Brooks                   375296621408
  610. Carol                    Richardson               375296621558
  611. Eugene                   Miller                   375296651008
  612. Shirley                  Morris                   375296012448*/
  613.  
  614.  
  615.  
  616. -- 5) Информация об отделениях с максимальным количеством сотрудников
  617. -- Упростить
  618. CREATE OR REPLACE VIEW BranchWithMaxPersonnel AS
  619. SELECT b.city BRANCH_CITY, b.street BRANCH_STREET, b.tel_no BRANCH_TEL_NO
  620. FROM BranchVSHKL b
  621. WHERE b.bno IN(
  622.     SELECT BNO
  623.     FROM(
  624.         SELECT s.bno, COUNT(s.bno) COUNT_BNO
  625.         FROM StaffVSHKL s
  626.         GROUP BY s.bno
  627.         )
  628.     WHERE COUNT_BNO =
  629.         (
  630.         SELECT MAX(COUNT_BNO)
  631.         FROM(
  632.             SELECT s.bno, COUNT(s.bno) COUNT_BNO
  633.             FROM StaffVSHKL s
  634.             GROUP BY s.bno
  635.             )
  636.         )  
  637.     );
  638.  
  639. SELECT * FROM BranchWithMaxPersonnel;
  640.  
  641. /*  BNO   CITY     STREET        TEL_NO
  642.     ----- -------- ------------- ------------
  643.     1332  Minsk    Kabushkina    375296954454
  644.     1325  Minsk    Timiryazeva   375296545454
  645.     1346  Minsk    Pritytskogo   375296651754
  646.     1367  Grodno   Kirova        375296541004  */
  647.  
  648.  
  649.  
  650. -- 6) Информация о сотрудниках и объектах ими представляемыми
  651. CREATE OR REPLACE VIEW StaffAndRent AS
  652. SELECT S.bno, S.fname, S.lname, S.tel_no STAFF_TEL,
  653.        P.street RENT_STREET, P.city RENT_CITY, P.TYPE, P.rooms, P.rent
  654. FROM StaffVSHKL S, PropertyForRentVSHKL P
  655. WHERE S.sno = P.sno;
  656.  
  657. SELECT * FROM StaffAndRent;
  658.  
  659.  
  660.  
  661. -- 7) Информация о владельцах, чьи дома осматривали арендаторы
  662. -- Упростить [done]
  663. CREATE OR REPLACE VIEW OwnersViewed AS
  664. SELECT DISTINCT O.fname, O.lname, O.address, O.tel_no
  665. FROM OwnerVSHKL O, PropertyForRentVSHKL P, ViewingVSHKL V
  666. WHERE O.ono = P.ono AND V.pno = P.pno;
  667.  
  668. SELECT * FROM OwnersViewed;
  669.  
  670.  
  671.  
  672. -- Все запросы
  673. -- 1)
  674. SELECT * FROM BranchesInVitebsk;
  675. -- 2)
  676. SELECT * FROM MinimalPrice;
  677. -- 3)
  678. SELECT * FROM NumberOfViewsWithComment;
  679. -- 4)
  680. SELECT * FROM RentersWhoWantFlatWith3Rooms;
  681. -- 5)
  682. SELECT * FROM BranchWithMaxPersonnel;
  683. -- 6)
  684. SELECT * FROM StaffAndRent;
  685. -- 7)
  686. SELECT * FROM OwnersViewed;
  687.  
  688.  
  689.  
  690. -- Vita
  691. -- MAX AVG 2 rooms branch
  692. SELECT *
  693. FROM PropertyForRentVSHKL p
  694. WHERE p.rooms = 2;
  695.  
  696. SELECT AVG(RENT)
  697. FROM(
  698.     SELECT *
  699.     FROM PropertyForRentVSHKL p
  700.     WHERE p.rooms = 2  
  701.     )
  702. WHERE p.bno IN(
  703.     SELECT bno
  704.     FROM(
  705.             SELECT *
  706.         FROM PropertyForRentVSHKL p
  707.         WHERE p.rooms = 2
  708.         )
  709. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement