vineri, 26 februarie 2010

O iesire… undeva… [1] ( By Refu )

O iesire… undeva… [ By Kissulescu / ReFuZaKe ]
Dupa o dimineata in care ma simteam bine, totul mergand usor de la o trezire din pat usoara, o viteza pana la baie sa ma spal pe fata sa miros dimineata mai bine, ma imbrac pe fundal de muzica, am decis sa deschid pc-ul pentru 4-5 minute sa ma bucur din plin de dimineata, afara un soare de te face sa te urci pe munti, dupa ce sunt pregatit zbor spre servici, totul minunat ies la sosea vine autobuzul, ma urc si pornesc la drum.
Ajung la servici o zi lejera fara prea multa bataie de cap, dupa ce ies de la servici pentru ca totul a mers minunat, de ce sa nu continui ziua asa, iau telefonul caut in agenda.. A…B…C….D…Dan Cosmote, bun de el am nevoie, il sun.. ( suna de 2 ori ):
Dan: Da?
Eu: Salut tipule, ce faci iesi pe undeva azi ?
Dan: Hmm, da omule, hai ca ies de la servici in 40 de minute si ne auzim, vii la mine ?
Eu: Da acuma am iesit si eu de la servici, vin spre tine.
Bun, totul este aranjat dar lipseste ceva, ah da, lipseste o piesa care sa ma binedispuna, asa ca imi pun castile pe urechi si caut in playlist, ajung la
Cas Haley – Walking On The Moon, imi zic, perfecta !!!
Piesa canta si eu binedispus plec catre Dan, in drum spre el imi suna telefonul, era Dan.
Eu: Da, tipule spune, ce este?
Dan: Pai te-am sunat sa-ti zic ca am un chef de un film!
Suntem in Septembrie si la cinema era The Ugly Truth, zic hai ca merge.
Eu: Bine tipule, suna excelent hai ca ajung la tine in 25 de minute si mergem spre cinema, unde il vedem ?
Dan: Pai ma gandeam sa il vedem la Plaza Romania, pe Lujerului.
Eu: Ok!!!
Dan:Dar apare o mica problema !
Eu: Care? Ce ai mai facut ?
Dan:Ah, nimic doar ca trebuie sa astept inca 30 de minute un coleg de munca sa iasa, si de aia trebuie sa il astept.
Eu: La naiba, pai si filmul cand este?
Dan:Lasa, ca ajungem la film, venim cu masina lui ajungem imediat, dar nu stiu unde sa ne astepti, cred ca cel mai bine este sa ne vedem in fata la cinema, ce zici ?
Eu: Ok, hai ca o sa plec spre film, si ne vedem acolo.
Plec spre Plaza, si in drum spre metrou dau drumu la muzica din nou, eram pe la Obor.
Cand se face timpul sa ajunga baieti, imi suna telefonul !
Dan: Bai Andrei, fii atent !
Deja m-a luat cu bai, Andrei, deja stiam ca s-a intamplat ceva !
Eu: Te ascult, ce s-a intamplat, nu vad pe nimeni pe aici…
Dan: Pai da, sti, baietii au decis sa mergem la biliard, deci nu mai mergem la film.
Eu: Superb, bine hai ca vad eu ce fac.
Dan: Stai.. ( si-am inchis )
Acuma putin nervos ca nu am fost niciodata la film singur, am zis ce naiba, ce aiurea si cu astia zic ceva si fac cu totul altceva, asta e.
Si decid sa ma duc singur in cinema, ajung acolo bineinteles mult mai devreme imi iau un bilet central, si pentru ca aveam destul timp am decis sa mai ma plimb, am coborat jos la parter, si in timp ce ma uitam la un magazin de haine, vine o fata cu niste ochii de parca m-a trezit din nervozitatea care o aveam, si-mi spune:
Ea: Buna, scuza-ma ca te intrerup ( se uita la mine si la camasa din raft si zambeste usor spre partea stanga )
Eu: Da, spune…
Ea: Sti cumva unde este cinema-ul ?
Eu: Hmm, astepti filmul de 18.15?
Ea: Da, da exact accela !
Eu: Suna bine, pai la ala am si eu bilet, tu ai bilet?
Ea: Sti, inca nu mi-am luat biletul inca pentru ca sunt deja cu niste prietenele
Eu: Pai sunt cumva imaginare? ( Zambesc putin dar nu prea serios )
Ea: Sti, eu ma cam grabesc, ele sunt sus, ma poti ajuta sau intreb pe altcineva.
Eu: Ok, pai cinema-ul este la etajul 3, sunt scarile rulante care te duc la etajul 3.
Ea: Mersi.
Eu: Cu placere… ( Ea deja se grabea sa urce la etajul 3 )
Eu: Mi-a facut si mie placere sa te cunosc ( Asta dupa ce ea era deja pe scari, si eu o priveam ce singura pare in tot magazinul )
Mai ma uitam la 2-3 camasi care erau la magazinul de la parter, si ma uit la ceas mai erau 15 minute si incepea filmul, gata era timpul sa urc, daca vreau sa mai prind vre-un pop-corn.
Ajung sus ma pregatesc sa intru cand… o vad pe EA, statea cu biletul in mana si se uita in stanga si in dreapta.
Cu un zambet subtire, ma indrept spre ea si ii spun:
Eu: Ori prietenele tale sunt imaginare, ori esti vrajitoare si le-ai facut sa dispara.
Ea: ( Rade putin ) Hai nu mai face si tu misto de mine, prietenele mele au plecat deja, si-au schimbat planul.
Eu: Pe ce te-au tradat?
Ea: Poftim ?
Eu: Pai de ce au plecat?
Ea: Aaa, sti, ele urma sa ajunga si la o petrecere in seara asta si nu stiu de ce, dar am ales film-ul.
Eu: Interensat…
Ea: Ce este asa interesant…
Eu: Pai eu am fost tradat pentru 2-3 ore de biliard, asa ca am ajuns singur la film.
Ea: ( Se uita in alta parte si zambeste usor ) Frumos !
Eu: Da, putem sa ne inscriem prietenii la un concurs pentru cei mai tari prieteni, si nu pariem pe ei, sigur castigam
Ea: ( Rade putin ) Eh nici chiar asa, ele de fel se tin de cuvant, nu stiu ce s-a intamplat in seara asta.
Eu: Bun, pai prietenii ne-au lasat, tu ai bilet la fel am si eu, il vedem sau vindem biletele pe 1 sticla de cola ?
Ea: Nuuuuu.
Eu: ( O iau de mana ) Atunci avem o misiune, sa vedem filmul pana la capat.
Ea: Bineinteles…
Dupa ce ajungem in sala observam ca diferenta dintre noi era undeva de 6 scaune, si 2 randuri diferenta, ambele locuri centrale.
Sfarsit Partea 1 !!!

miercuri, 24 februarie 2010

Quiz: Count, Distinct, NVL

Test: Quiz: Count, Distinct, NVL
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1

1. To include null values in the calculations of a group function, you must: Mark for Review
(1) Points


Precede the group function name with NULL


Count the number of null values in that column using COUNT


Convert the null to a value using the NVL( ) function (*)


Group functions can never use null values



Correct Correct


2. Using your existing knowledge of the employees table, would the following two statements produce the same result?

SELECT COUNT(*)
FROM employees;

SELECT COUNT(commission_pct)
FROM employees;
Mark for Review
(1) Points


The first statement is invalid


Yes


No (*)


The second statement is invalid



Correct Correct


3. What would the following SQL statement return?

SELECT COUNT(first_name)
FROM employees;
Mark for Review
(1) Points


A listing of all non-null first names in the employees table


The total number of non-null first names in the employees table (*)


The total number of rows in the employees table


A listing of all unique first names in the employees table



Correct Correct


4. What would the following SQL statement return?

SELECT COUNT(DISTINCT salary)
FROM employees;

Mark for Review
(1) Points


A listing of all unique salaries in the employees table


The total number of rows in the employees table


The total amount of salaries in the employees table


The number of unique salaries in the employees table (*)



Correct Correct


Page 1 of 1 Summary

( Vrei sa traduci ceva?Want to translate something? http://translate.google.ro/# )

Quiz: Group Functions

Test: Quiz: Group Functions
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1

1. The following statement will work even though it uses the same column with different GROUP functions:
SELECT AVG(salary), MAX(salary), MIN(salary), SUM(salary)
FROM employees;

True or False?

Mark for Review
(1) Points


True (*)


False



Correct Correct


2. Given the following data in the employees table (employee_id, salary, commission_pct)

DATA: (143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)

What is the result of the following statement:

SELECT SUM(commission_pct), COUNT(commission_pct)
FROM employees
WHERE employee_id IN( 143,144,149,174,176,178)

Mark for Review
(1) Points


SUM = .85 and COUNT = 6


SUM = 1.85 and COUNT = 6


SUM = .85 and COUNT = 4 (*)


SUM = 1.85 and COUNT = 4



Correct Correct


3. Given the following data in the employees table (employee_id, salary, commission_pct)

DATA: (143, 2600, null
144, 2500, null
149, 10500, .2
174, 11000, .3
176, 8600, .2
178, 7000, .15)

What is the result of the following statement:

SELECT AVG(commission_pct)
FROM employees
WHERE employee_id IN( 143,144,149,174,176,178)

Mark for Review
(1) Points


1.2125


This statement is invalid


0.2125 (*)


0.0425



Correct Correct


4. What would the following SQL statement return?
SELECT MAX(hire_date)
FROM employees;

Mark for Review
(1) Points


The hire date of the longest serving employee


The hire date of the newest employee (*)


The hire dates of all employees in ascending order


The hire dates of all employees



Correct Correct


5. What two group functions can be used with any datatype? Mark for Review
(1) Points


STDDEV, VARIANCE


SUM, AVG


COUNT, SUM


MIN, MAX (*)



Correct Correct


6. You can use GROUP functions in all clauses of a SELECT statement. True or False? Mark for Review
(1) Points


True


False (*)



Correct Correct


Page 1 of 1 Summary

( Vrei sa traduci ceva?Want to translate something? http://translate.google.ro/# )

Quiz: Cross joins and Natural Joins

Test: Quiz: Cross joins and Natural Joins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1

1. What happens when you create a Cartesian product? Mark for Review
(1) Points


All rows from one table are joined to all rows of another table (*)


No rows are returned as you entered wrong join-criteria


The table is joined to itself, one column to the next column, exhausting all possibilities


All rows that do not match in the WHERE clause are displayed



Correct Correct


2. A NATURAL JOIN is based on: Mark for Review
(1) Points


Columns with the same name and datatype (*)


Columns with the same name


Columns with the same datatype and width


Tables with the same structure



Correct Correct


3. The join column must be included in the select statement when you use the NATURAL JOIN clause. True or False? Mark for Review
(1) Points


True


False (*)



Correct Correct


4. The ___________ join is the ANSI-standard syntax used to generate a Cartesian product. Mark for Review
(1) Points


NATURAL


ALL


FULL


CROSS (*)



Correct Correct

( Vrei sa traduci ceva?Want to translate something? http://translate.google.ro/# )

Quiz: Join Clauses

Test: Quiz: Join Clauses
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1

1. The primary advantage of using JOIN ON is: Mark for Review
(1) Points


The join happens automatically based on matching column names and data types


It will display rows that do not meet the join condition


It easily produces a Cartesian product between the tables in the statement


It permits columns that don?t have matching data types to be joined


It permits columns with different names to be joined (*)



Correct Correct


2. The keywords JOIN _____________ should be used to join tables with the same column names but different datatypes. Mark for Review
(1) Points


NATURAL ON


ON


WHEN


USING (*)



Correct Correct


3. The following is a valid SQL statement.

SELECT e.employee_id, e.last_name, d.location_id, department_id
FROM employees e JOIN departments d
USING (department_id) ;

True or False?
Mark for Review
(1) Points


True (*)


False



Correct Correct


4. Table aliases MUST be used with columns referenced in the JOIN USING clause. True or False? Mark for Review
(1) Points


True


False (*)



Correct Correct


5. You can do nonequi-joins with ANSI-Syntax. True or False? Mark for Review
(1) Points


True (*)


False



Correct Correct



( Vrei sa traduci ceva?Want to translate something? http://translate.google.ro/# )

Quiz: Inner versus Outer Joins

Test: Quiz: Inner versus Outer Joins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1

1. If you select rows from two tables (employees and departments) using an outer join, what will you get? Use the code below to arrive at your answer:

SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d
ON (e.department_id = d.department_id);
Mark for Review
(1) Points


All employees that do not have a department_id assigned to them


All employees including those that do not have a department_id assigned to them (*)


No employees as the statement will fail


None of the above



Correct Correct


2. What is another name for a simple join or an inner join? Mark for Review
(1) Points


Nonequijoin


Equijoin (*)


Self Join


Outer Join



Correct Correct


3. EMPLOYEES Table:
Name Null? Type
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
DEPARTMENT_ID NUMBER (4)

DEPARTMENTS Table:
Name Null? Type
DEPARTMENT_ID NOT NULL NUMBER 4
DEPARTMENT_NAME NOT NULL VARCHAR2(30)
MANAGER_ID NUMBER (6)

A query is needed to display each department and its manager name from the above tables. However, not all departments have a manager but we want departments returned in all cases. Which of the following SQL: 1999 syntax scripts will accomplish the task?
Mark for Review
(1) Points


SELECT d.department_id, e.first_name, e.last_name
FROM employees e
LEFT OUTER JOIN departments d
WHERE (e.department_id = d.department_id);



SELECT d.department_id, e.first_name, e.last_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.employee_id = d.manager_id);

(*)


SELECT d.department_id, e.first_name, e.last_name
FROM employees e
FULL OUTER JOIN departments d ON (e.employee_id = d.manager_id);



SELECT d.department_id, e.first_name, e.last_name
FROM employees e, departments d
WHERE e.employee_id RIGHT OUTER JOIN d.manager_id;




Correct Correct


4. Given the following descriptions of the employees and jobs tables, which of the following scripts will display each employee?s possible minimum and maximum salaries based on their job title?

EMPLOYEES Table:
Name Null? Type
EMPLOYEE_ID NOT NULL NUMBER (6)
FIRST_NAME VARCHAR2 (20)
LAST_NAME NOT NULL VARCHAR2 (25)
EMAIL NOT NULL VARCHAR2 (25)
PHONE_NUMBER VARCHAR2 (20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2 (10)
SALARY NUMBER (8,2)
COMMISSION_PCT NUMBER (2,2)
MANAGER_ID NUMBER (6)
DEPARTMENT_ID NUMBER (4)

JOBS Table:
Name Null? Type
JOB_ID NOT NULL VARCHAR2 (10)
JOB_TITLE NOT NULL VARCHAR2 (35)
MIN_SALARY NUMBER (6)
MAX_SALARY NUMBER (6)
Mark for Review
(1) Points


SELECT e.first_name, e.last_name, e.job_id, j.min_salary, j.max_salary
FROM employees e
NATURAL JOIN jobs j
USING (job_id);



SELECT first_name, last_name, job_id, min_salary, max_salary
FROM employees
NATURAL JOIN jobs;

(*)


SELECT e.first_name, e.last_name, e.job_id, j.min_salary, j.max_salary
FROM employees e
NATURAL JOIN jobs j;



SELECT first_name, last_name, job_id, min_salary, max_salary
FROM employees e
FULL JOIN jobs j (job_id);



SELECT e.first_name, e.last_name, e.job_id, j.min_salary, j.max_salary
FROM employees e
NATURAL JOIN jobs j ON (e.job_title = j.job_title);




Correct Correct


5. Which syntax would be used to retrieve all rows in both the EMPLOYEES and DEPARTMENTS tables, even when there is no match? Mark for Review
(1) Points


FULL OUTER JOIN (*)


LEFT OUTER JOIN AND RIGHT OUTER JOIN


FULL INNER JOIN


Use any equijoin syntax



Correct Correct


6. The following statement is an example of what kind of join?

SELECT car.vehicle_id, driver.name
FROM car
LEFT OUTER JOIN driver ON (driver_id) ;
Mark for Review
(1) Points


Inner Join


Outer Join (*)


Equijoin


Optimal Join



Correct Correct


7. For which of the following tables will all the values be retrieved even if there is no match in the other?

SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
Mark for Review
(1) Points


employees (*)


department


both


Neither. the LEFT OUTER JOIN limits the value to the matching department id's.



Correct Correct


Page 1 of 1 Summary

( Vrei sa traduci ceva?Want to translate something? http://translate.google.ro/# )

Quiz: Outer Joins

Test: Quiz: Outer Joins
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 1

1. The ID column in the CLIENT table that corresponds to the CLIENT_ID column of the ORDER table contains null values for rows that need to be displayed. Which type of join should you use to display the data? Mark for Review
(1) Points


Equijoin


Self join


Outer join (*)


Nonequi-Join



Correct Correct


2. To perform a valid outer join between DEPARMENTS and EMPLOYEES to list departments without employees select the correct WHERE clause for the following select statement:

SELECT d.department_name, e.last_name
FROM employees e, departments d
WHERE
Mark for Review
(1) Points


e.department_id(+) = d.department_id (*)


e.department_id(+) = d.department_id(+)


e.department_id = d.department_id(+)


e.department_id = d.department_id



Correct Correct


3. The following is a valid outer join statement:

SELECT c.country_name, d.department_name
FROM countries c, departments d
WHERE c.country_id (+) = d.country_id (+)

True or False?
Mark for Review
(1) Points


True


False (*)



Correct Correct


4. Which symbol is used to perform an outer join? Mark for Review
(1) Points


*


||


(+) (*)


#



Correct Correct

( Vrei sa traduci ceva?Want to translate something? http://translate.google.ro/# )