RDBMS Expertise - Page 29
-
Résultat Test SQL ANSI
-
SQL ANSI - TEST
https://lamp-dev.com/elance-ansi-sql-code-test-with-answers/109
1. Consider a table named “salary” having the following columns:
“id” (type: INT)
“salary” (type: INT)
“incentive” (type: INT)
“tax” (type: INT)
Write a standard SQL query which will update the tax column with the sum of 10% of salary and 2% of incentive, for those salaries which are more than 15000.
UPDATE salary SET tax = 0.1*salary+0.02*incentive WHERE salary > 15000
2. Consider a table named “employee” having the following columns:
“empid” (type: INT)
“empname” (type: TEXT)
“salary” (type: INT)
Write a standard SQL query which retrieves the empnames whose values start with the string ‘john’ followed by any characters.
SELECT empname FROM employee WHERE empname LIKE 'john%'
3. Consider a table named “employee” having the following columns:
“empid” (type: INT)
“empname” (type: TEXT)
“salary” (type: INT)
Write a standard SQL query which retrieves the number of rows where the salary is not null. The returned value should be represented using the column name “validsalarycount”.
SELECT count(salary) AS validsalarycount FROM employee WHERE salary IS NOT NULL
4. Consider a table named “store” having the following columns:
“storename” (type: TEXT)
“sales” (type: INT)
“Date” (type: DATE)
Write a standard SQL query which retrieves the storenames, whose sales lie between 100 and 2000 (not inclusive). The storenames should not be repeated.
SELECT DISTINCT storename FROM store WHERE sales > 100 AND sales < 2000
5. Consider a table named “staff” having the following column structure:
“empid” (type: INT)
“empname” (type: TEXT)
“salary” (type: INT)
Write a standard SQL query which retrieves the sum of 75 percent of the salaries from the staff table (only salaries above 5000 are to be considered). The returned value should be represented using the column name ‘total’.
SELECT sum(0.75*salary) AS total FROM staff WHERE salary > 5000
6. Consider the following tables:
department
———-
deptid (type: INT)
deptname (type: TEXT)
hours (type: INT)
active (type: BIT)
employee
——–
empid (type: INT)
empname (type: TEXT)
deptid (type: INT)
designation (type: TEXT)
salary (type: INT)
Write a query to return the columns empname and deptname of the employees belonging to those departments that have a head count of 4 or more. The records should be returned in alphabetical order of empname.
SELECT e.empname, d.deptname FROM department d INNER JOIN employee e WHERE e.deptid=d.deptid
WHERE e.deptid IN ( SELECT e.deptid FROM employee d GROUP BY e.deptid HAVING COUNT(e.deptid) >=4 ) ORDER BY e.empname ASC;
7. Consider a table called carrecords with the following structure:
name (type: TEXT)
price (type: INT)
color (type: TEXT)
vehicletype (type: TEXT) eg. SEDAN/SUV
A customer wants to see the details (name, price, color, vehicletype) of the vehicles that suit his preferences. This is what he says:
Write a query to return the columns empname and deptname of the employees belonging to those departments that have a head count of 4 or more. The records should be returned in alphabetical order of empname.
“If its a black sedan, I’m ready to pay 10,000, but if its red or white, then no more than 8,000. For any other color I won’t go above 7,000, except if its an SUV, in which case my budget is upto 15,000 for a black one or upto 14,000 for any other color.”
SELECT name, price, color, vehicletype FROM carrecords WHERE
(vehicletype = 'SEDAN' AND color = 'black' AND price <= 10000)
OR (vehicletype = 'SEDAN' AND color IN('red','white') AND price <= 8000 )
OR (vehicletype = 'SUV' AND color = 'black' AND price <= 15000)
OR (vehicletype = 'SUV' AND color != 'black' AND price <= 14000)
OR (price <= 7000)
ORDER BY price ASC
SELECT name, price, color, vehicletype FROM carrecords WHERE vehicletype = 'SEDAN' AND color = 'BLACK' AND price <= 10000 UNION
SELECT name, price, color, vehicletype FROM carrecords WHERE vehicletype = 'SEDAN' AND color IN ('red','white') AND price <= 8000 UNION
SELECT name, price, color, vehicletype FROM carrecords WHERE vehicletype = 'SEDAN' AND color NOT IN('RED','WHITE','BLACK') AND price <= 7000 UNION
SELECT name, price, color, vehicletype FROM carrecords WHERE vehicletype = 'SUV' AND color = 'BLACK' AND price <= 15000 UNION
SELECT name, price, color, vehicletype FROM carrecords WHERE vehicletype = 'SUV' AND color != 'BLACK' AND price <= 14000)
ORDER BY price ASC;
8. Consider a database with a table called “accounts”, having two fields:
“entrydate” (type: DATE)
“accountno” (type: INT)
Write a SQL query which returns the accountno of the most recent entrydate. The returned value should be represented using the column name, “accountno”.
SELECT accountno FROM accounts ORDER BY entrydate DESC LIMIT 0,1;
9. Consider a table called “students”, having the following column fields:
“id” (type: INT)
“name” (type: TEXT)
“marks” (type: INT)
Write a SQL query which will calculate the average of the marks of the students passing. The passing criteria is that the marks should be at least 40. The average marks are to be returned using the column name ‘marksaverage’.
SELECT avg(marks) AS marksaverage FROM students WHERE id IN (SELECT id FROM students WHERE marks >= 40)
10. Consider a table called “department”, having the following columns:
“id” (type: INT)
“deptname” (type: TEXT)
“rank” (type: INT)
Write a SQL query which will return the deptnames of the departments whose rank lies between 2 and 5 (inclusive). The results should be returned in increasing order of rank (rank 3 being higher than rank 6).
SELECT deptname FROM department WHERE rank >= 2 AND rank <= 5 ORDER BY rank ASC -
Note de frais en CDI
Se faire rembourser ses notes de frais dans le cadre d'un CDI, c'est possible, en voici la preuve ici.
https://www.juritravail.com/chiffres-et-indices/frais-professionnels-allocations-forfaitaires-limites-exoneration.html
-
L'avenir d'Oracle
La technologie Spark va t-elle supplanter les monstres comme Oracle?
Quel est l'avenir pour Apache Hive?
-
La marcheuse Christine and the Queens
La marcheuseJ’vais marcher très longtemps
Et je m’en vais trouver les poings qui redessinent
J’vais chercher éhontément
Les coups portés sur moi, la violence facileJ’vais marcher tout le temps
Et je m’en vais forcer les regards agressifs
J’vais toujours au-devant
Il me tarde de trouver la violence facile, c'estNoël en mai, j’ai rien bu
Bas de l’immeuble, t'as rien vu
Quand moi j’avance furieuse
Toute débaguée, les lèvres blêmesAttire à moi les oiseaux
Le sang séché sur ma peau
Les gens sourient de peur que ma maladie de boxeur se prêteJ’vais marcher très longtemps
Et je m’en vais trouver les poings qui redessinent
J’vais chercher éhontément
Les coups portés sur moi, la violence facileJ’vais marcher tout le temps
Et je m’en vais forcer les regards agressifs
J’vais…The walker
[Chorus]
I am out for a walk
And I will not be back til they're staining my skin
This is how I chose to talk
With some violent hits, violet blossoms akin
Every night I do walk
And if they're looking down I'm offering my chin
This is how I chose to talk
With some violent hits, violet blossoms akin
[Verse 1]
There's
A way to truly be seen
By furiously skimming in
Forget the jewels, I'm livid
Veins are jutting out fine on their own
Blood on my cheeks, birds come by
One of my stomps and they fly
People politely smile to make sure I won't come any closer
[Chorus]
I am out for a walk
And I will not be back til they're staining my skin
This is how I chose to talk
With some violent hits, violet blossoms akin
Every night I do walk
And if they're looking down I'm offering my chin
This is how I chose to talk
With some violent hits, violet blossoms akin
[Verse 2]
Now
A swollen eye is four days
Of curious calm, snow in May
Way better off on my own
Since no one cries there's no one to blame
It hurts, I feel everything
As my sense of self's wearing thin
Such pains can be a delight
Far from when I could drown in my shame
[Chorus]
I am out for a walk
And I will not be back til they're staining my skin
This is how I chose to talk
With some violent hits, violet blossoms akin
Every night I do walk
And if they're looking down I'm offering my chin
This is how I chose to talk
With some violent hits, violet blossoms akinTraductionJe suis en promenade Et je ne reviendrai pas jusqu'à ce qu'ils se colorent ma peau Voici comment j'ai choisi de parler Avec quelques coups violents, les fleurs violettes ressemblent Chaque nuit je marche Et s'ils regardent, j'offre mon menton Voici comment j'ai choisi de parler Avec quelques coups violents, les fleurs violettes ressemblent [Verset 1] Il y a Un moyen d'être vraiment vu En parcourant furieusement Oublie les bijoux, je suis livide Les veines saillent bien tout seul Du sang sur mes joues, les oiseaux passent Un de mes coups et ils volent Les gens sourient poliment pour s'assurer que je ne m'approche pas [Refrain] Je suis en promenade Et je ne reviendrai pas jusqu'à ce qu'ils se colorent ma peau Voici comment j'ai choisi de parler Avec quelques coups violents, les fleurs violettes ressemblent Chaque nuit je marche Et s'ils regardent, j'offre mon menton Voici comment j'ai choisi de parler Avec quelques coups violents, les fleurs violettes ressemblent [Verset 2] À présent Un œil enflé, c'est quatre jours De curieux calme, neige en mai Bien mieux par moi-même Puisque personne ne pleure, il n'y a personne à blâmer Ça fait mal, je sens tout Comme mon sens de soi est mince De telles douleurs peuvent être un délice Loin de me noyer dans ma honte [Refrain] Je suis en promenade Et je ne reviendrai pas jusqu'à ce qu'ils se colorent ma peau Voici comment j'ai choisi de parler Avec quelques coups violents, les fleurs violettes ressemblent Chaque nuit je marche Et s'ils regardent, j'offre mon menton Voici comment j'ai choisi de parler Avec quelques coups violents, les fleurs violettes ressemblent
-
Méthode de prospection pour devenir freelance
_s'inscrire sur les sites généralistes https://www.freelance-info.fr/ https://www.freelance.com/,
_candidater aux missions en cours en evnoyant son cv en postulant comme freelance,
_s'inscrire sur les sites des ESN comme HAYS, AKKA, CELAD…Ou encore, les sites des cabinets spécialisés dans le recrutement de freelance (Mushroom, Urban Linker, Agence-e),
_avoir un profil linkedin à jour, un profil malt à jour. -
Des vacances hédonistes
Des vacances pour les hédonistes ?
Oui! et ça se passe ici .
-
Rambo is back
-
Un article hyper intéressant et d'actualité sur la protection des données
-
Tracer sql query dans base oracle
• Pour tracer les requêtes SQL dans une base Oracle il faut passer la commande :
execute dbms_monitor.database_trace_enable(waits=>TRUE,binds=>TRUE,instance_name=>'QUALIF');
• Pour stopper la trace :
execute dbms_monitor.database_trace_disable(instance_name=>'QUALIF');
• La trace sera stockée sous :
select
value
from
v$diag_info
where
name ='Default Trace File';
Exemple :
/export/BD/ORACLE/oratrc/QUALIF/bdump/diag/rdbms/qualif/QUALIF/trace/QUALIF_ora_58689.trc
Elle pourra être lisible avec tkprof :
Syntaxe : tkprof <nom_de_la_trace> <nom_du_fichier_texte_lisible> sys=no
Exemple:
$tkprof QUALIF_ora_7767.trc QUALIF_ora_7767.txt sys=no
L’option sys = no ne garde pas les requêtes lancées par l’utilisateur sys.