SQL requests

First some more easy sql requests.

Select all table records

SELECT * FROM Departments

Select any column from table

SELECT Name FROM Departments

Select concat names and put FullName for column name

SELECT CONCAT(FirstName, ' ', LastName) FullName FROM Employees

Select non-repeated names (DISTINCT)

SELECT DISTINCT Salary FROM Employees

Select records that have given JobTitle

SELECT * FROM Employees e
WHERE JobTitle = 'Sales Representative'

Select two columns where name have ei somewhere in it

SELECT FirstName, LastName FROM Employees
WHERE LastName like '%ei%'

Select Salery where it is between any values

SELECT Salary FROM Employees e
WHERE Salary BETWEEN 20000 AND 30000

Select Employees where their salaty is any of given values(in)

SELECT FirstName, LastName FROM Employees
WHERE Salary IN (25000, 14000, 12500, 23600)

Select Employees and sort them(in)

SELECT FirstName, LastName, Salary FROM Employees
WHERE Salary > 50000
ORDER BY Salary DESC

Select first 5 Employees (top)

SELECT TOP 5 FirstName, LastName, Salary FROM Employees
WHERE Salary > 50000
ORDER BY Salary DESC

More complicated sql requests.

Join data from different tables

SELECT FirstName, LastName, AddressText
FROM Employees e
JOIN Addresses a
ON e.AddressID = a.AddressID

or

SELECT FirstName, LastName, AddressText
FROM Employees e, Addresses a
WHERE e.AddressID = a.AddressID

Join data from three tables

SELECT CONCAT(e.FirstName, ' ', e.LastName) AS FullName,  CONCAT(m.FirstName, ' ', m.LastName) ManagerFullName, a.AddressText
FROM Employees e
JOIN Employees m
on e.ManagerID = m.EmployeeID
JOIN Addresses a
on e.AddressID = a.AddressID

Nested select with agregate function(function that return number)

SELECT CONCAT(FirstName, ' ', LastName) AS FullName, Salary
FROM Employees
WHERE Salary = (SELECT MIN(Salary) FROM Employees)

Find the full name, salary and department of the employees that take the minimal salary in their department

We have one join and where for salary equal to min salary by departments

SELECT CONCAT(FirstName, ' ', LastName) AS FullName, Salary, d.Name
FROM Employees e JOIN Departments d
ON d.DepartmentID = e.DepartmentID
WHERE Salary =
    (SELECT MIN(Salary) FROM Employees
    WHERE DepartmentID = e.DepartmentID)
    order by d.Name

Find the average salary in the “Sales” department

SELECT AVG(Salary) [Avarage Salary] FROM Employees e
JOIN Departments d
ON e.DepartmentID = d.DepartmentID
WHERE d.Name = 'Sales'

Find the number of all employees that have manager

SELECT COUNT(*) [Count Employees]
FROM Employees e
WHERE ManagerID IS NOT NULL

Find all departments and the average salary for each of them

When we have aggregate function and colum we must group records by column name.

SELECT d.Name [Department], AVG(Salary) [Avarage Salary]
FROM Employees e
JOIN Departments d
ON e.DepartmentID = d.DepartmentID
GROUP BY d.Name

Find all managers that have exactly 5 employees

When we have grouping and must filter by something we use HAVING.

SELECT CONCAT(e.FirstName, ' ', e.LastName) ManagerName, COUNT(*) [Count Employees]
    FROM Employees e
    JOIN Employees em
    ON em.ManagerID = e.EmployeeID
    GROUP BY e.FirstName, e.LastName
    HAVING COUNT(*) = 5

or
we can create temporary table it nested select and make where on it

SELECT * FROM
    (SELECT CONCAT(e.FirstName, ' ', e.LastName) ManagerName, COUNT(*) [Count Employees]
    FROM Employees e
    JOIN Employees em
    ON em.ManagerID = e.EmployeeID
    GROUP BY e.FirstName, e.LastName) AS Managers
WHERE Managers.[Count Employees] = 5

Find all employees along with their managers. For employees that do not have manager display the value “(no manager)”.

We must use if statement in sql this is (case -> then -> else).

SELECT CONCAT(e.FirstName, ' ', e.LastName) AS FullName,
       CASE WHEN CONCAT(m.FirstName, ' ', m.LastName) <> ' '
       THEN CONCAT(m.FirstName, ' ', m.LastName)
       ELSE 'no manager' END AS ManagerFullName
FROM Employees e
LEFT JOIN Employees m
on e.ManagerID = m.EmployeeID

Use LEN for string length.

SELECT CONCAT(e.FirstName, ' ', e.LastName) ManagerName
    FROM Employees e
    WHERE LEN(e.LastName) = 5

Get date in a specific format.

The format must be given with numbers.

SELECT CONCAT(
    CONVERT(varchar, GETDATE(), 104),
    ' ',
    CONVERT(varchar, GETDATE(), 114))

2048

Play Game  Click Here  –> 2048 Game

  • How to play 2048 Game:

    Use your arrow keys to move the tiles. When two tiles with the same number touch, they merge into one!

  • 2048 Game Tips And Tricks

    1. Take it Slow

    2048 is so easy to play, you might get into the habit of tearing through games without even really paying attention to what you’re doing. That’s not a good idea. Take your time – there’s no penalty for thinking your moves through after all. Also, try to predict where new blocks might come in and how you could deploy them. Something like playing chess.

    2. Work The Corners

    In order to win the game you should have a specific strategy. If you do not have one, you will most probaly not reach furthr than 512. So, a good strategy is to always keep your hiest value tile at one of the corners. Just chooose one corner and direct all your tiles there. It is not as easy as it sounds, but you can master it quickly. In order to stop the highest value tile to leave “the king’s place”, try to pack tiles around it. Preferably, they should be the other biggest tiles. Master this simple strategy and you will soon reach 1024 and even win the 2048 Game!

    3. How to make the highest valued tile in the right bottom corner and not to move it?

    Once you have placed your highest tile value is in the right bottom corner, do not move it. To make sure it is not moved, you have to make the last row always filled by pushing the down arrow so that the use of LEFT and Right Arrow would not move the highest valued tile. Basically, this is the most important cheat for 2048 Game – keep the highest tile in the corner and do not move it.

              

      Do you still have free time after playing 2048?

 

 

 

 

 

 

CodeHunter

Play Game  Click Here  –> CodeHunter

  • Game History

He calls himself a Code Hunter.

He constantly leads battles with his new and old enemies  the CODES.

His final aim is to become Master Developer.

He uses hidden weapons against evil Bugs and crafty Codes to win this hard battle.

The most powerful weapon is his Motivation to keep on and to WIN in the End.

  • How to Play ?

Horizontal      ->    Right       d

Horizontal      <-    Left         a

Jump                   Space

Fire                           F

Weapon menu        P

Player Status          C

  • Start Menu:

 MainMenu

  • Select Level:

SelectLevels

  • Level 1:

Level1-Shoot

  • Game Menu:

Level1-Menu

  • Weapons Menu:

Level1-WeaponMenu

  • Equip:

Level 1 - Equip

  • Level 2:

Level 2

  • Final:

Level2-Final

  • About:

About