{"id":1988,"date":"2015-03-11T09:00:58","date_gmt":"2015-03-11T07:00:58","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=1988"},"modified":"2015-03-09T23:13:27","modified_gmt":"2015-03-09T21:13:27","slug":"sql-fejtoro-10","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2015\/03\/11\/sql-fejtoro-10\/","title":{"rendered":"SQL fejt\u00f6r\u0151 11."},"content":{"rendered":"<p>Feladat: van egy trading accountunk, ezen hol nyer\u00fcnk, hol veszt\u00fcnk. Az account nem mehet 0 al\u00e1, de ha nagyobb a vesztes\u00e9g\u00fcnk mint az account \u00e9rt\u00e9ke, a broker behajtja rajtunk a vesztes\u00e9get, vissza kell p\u00f3tolni a p\u00e9nzt. A feladat sz\u00e1mla mozg\u00e1sainak \u00f6sszegz\u00e9se.<\/p>\n<p>Az elv\u00e1rt kimenet az SQL tartalomban l\u00e1that\u00f3.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nUSE tempdb;\r\n\r\nIF OBJECT_ID(N'dbo.Trades', N'U') IS NOT NULL DROP TABLE dbo.Trades;\r\n\r\nCREATE TABLE dbo.Trades\r\n(\r\n  tradeId INT NOT NULL PRIMARY KEY,\r\n  amount  INT NOT NULL\r\n);\r\n\r\nINSERT INTO dbo.Trades(tradeId, amount)\r\n   values (1,12),(2,-25),(3,40),(4,10),(5,-23),(6,-32),(7,14),(8,-23),(9,12),(10,-20),(11,13),(12,-90);\r\nGO\r\n\r\n--Elv\u00e1rt kimenet:\r\n--tradeId\tamount\taccountValue\tmoneyBack\r\n--1\t12\t12\t0\r\n--2\t-25\t0\t13\r\n--3\t40\t40\t0\r\n--4\t10\t50\t0\r\n--5\t-23\t27\t0\r\n--6\t-32\t0\t5\r\n--7\t14\t14\t0\r\n--8\t-23\t0\t9\r\n--9\t12\t12\t0\r\n--10\t-20\t0\t8\r\n--11\t13\t13\t0\r\n--12\t-90\t0\t77\r\n<\/pre>\n<p>A megfejt\u00e9seket szok\u00e1s szerint kommentben v\u00e1rom, amelyeket 4 nap m\u00falva engedek ki.<\/p>\n<p>A <a href=\"http:\/\/soci.hu\/TddCourse.aspx\">Test Driven Development tanfolyam<\/a> k\u00f6vetkez\u0151 felvon\u00e1sa \u00e1prilis 20-\u00e1n lesz, j\u00f6v\u0151 h\u00e9t szerd\u00e1ig m\u00e9g 25% kedvezm\u00e9nnyel lehet jelentkezni!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Feladat: van egy trading accountunk, ezen hol nyer\u00fcnk, hol veszt\u00fcnk. Az account nem mehet 0 al\u00e1, de ha nagyobb a vesztes\u00e9g\u00fcnk mint&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4,30,93],"tags":[],"class_list":["post-1988","post","type-post","status-publish","format-standard","hentry","category-adatbazisok","category-szakmai-elet","category-sql-server","category-teaser"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1988"}],"version-history":[{"count":2,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1988\/revisions"}],"predecessor-version":[{"id":1992,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1988\/revisions\/1992"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}