1. Read
  2. Vote
  3. Old
  4. New
  5. Hot
  6. Reply

Tag : test


Top tags: CSS (7)   Wiki (3)   Feature (2)   CMS (2)   Bug (2)   Test (2)   Blog (1)   SIDU (1)   Forum (1)   Ticket (1)   Bank (1)   JS (1)   News (1)  


SQL row sum

Given an SQL table

ID Amt
-- ---
1 100
2 200
3 300

Please write a MySQL statement to produce the following result:

ID Amt Total
-- --- -----
1  100 100
2  200 300
3  300 600

And here is an example SQL:

SELECT a.ID, a.Amt, sum(b.Amt) AS Total
FROM tab AS a
JOIN tab AS b ON a.ID >= b.ID
GROUP BY 1,2
Cat: SIDU | Read: 12839 | 2018-11-02
Tag: Test

Finding the Nth Fibonacci number via PHP

Here is an example of Fibonacci numbers:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

Write a function f(x) so that return the following eg:

f(2) = 1 f(4) = 2 f(6) = 5 f(8) = 13 etc

And here is the code: function f($x = 0) { if ($x < 2) { return $x; } else { return f($x - 2) + f($x - 1); } }
Cat: General | Read: 56637 | Msg: 1 | 2018-11-01  1
Tag: Test

Category