{"id":13346,"date":"2019-12-15T13:48:04","date_gmt":"2019-12-15T13:48:04","guid":{"rendered":"https:\/\/ittutorial.org\/?p=13346"},"modified":"2019-12-15T13:58:52","modified_gmt":"2019-12-15T13:58:52","slug":"oracle-introduction-to-sql-tutorial-5","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/oracle-introduction-to-sql-tutorial-5\/","title":{"rendered":"Oracle Introduction to SQL Tutorial \u2013 5"},"content":{"rendered":"<p>Hi everyone, in this tutorial we will look the Date functions.\u00a0 Date functions in SQL Language are given below.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13347\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_1.png\" alt=\"\" width=\"1041\" height=\"289\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_1.png 1041w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_1-300x83.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_1-768x213.png 768w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_1-1024x284.png 1024w\" sizes=\"auto, (max-width: 1041px) 100vw, 1041px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>ADD_MONTHS Function<\/h3>\n<p>Used to add months to the date value that you type as a result of the SQL query<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>select * from student where surname='Federer';<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-13348\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_2.png\" alt=\"\" width=\"738\" height=\"547\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_2.png 561w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_2-300x222.png 300w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/p>\n<pre>select first_name,surname,Add_Months(birth_day,1)from student where surname='Federer';<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13349\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3.png\" alt=\"\" width=\"926\" height=\"326\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3.png 926w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-300x106.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-768x270.png 768w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Months_Between Functions<\/h3>\n<p>Used to find the month difference between two dates.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>select months_between('08-04-2019','08-01-2019') \"Between Months\" from dual;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13350\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4.png\" alt=\"\" width=\"892\" height=\"314\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4.png 892w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-300x106.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-768x270.png 768w\" sizes=\"auto, (max-width: 892px) 100vw, 892px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Next_Day Function<\/h3>\n<p>It adds the date of the week that you give to the date value that you give in SQL Query and gives the corresponding date information.<\/p>\n<p><span style=\"color: #0000ff\">Note: <span style=\"color: #000000\">The language definition of the day of the week may vary according to the &#8220;<strong>NLS_LANGUAGE<\/strong>&#8221; parameter.<\/span><\/span><\/p>\n<pre>select next_day('20-Jan-2019','Monday') as \"Next Monday\" from dual;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13370\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5.png\" alt=\"\" width=\"891\" height=\"277\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5.png 891w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-300x93.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-768x239.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Round Function<\/h3>\n<p>It is used to round the value you give in the SQL Query to minute \/ hour \/ day \/ week \/ month.<\/p>\n<ul>\n<li><span style=\"color: #339966\">DD: Day rounding.<\/span><\/li>\n<li><span style=\"color: #339966\">W:\u00a0\u00a0 Week rounding.<\/span><\/li>\n<li><span style=\"color: #339966\">MM: Month rounding.<\/span><\/li>\n<li><span style=\"color: #339966\">HH: Hour rounding.<\/span><\/li>\n<li><span style=\"color: #339966\">MI: M\u0131nute rounding.<\/span><\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<p>select round (to_date(&#8217;18-May-2019&#8242;),&#8217;MM&#8217;) as &#8220;Month Rounding&#8221; from dual;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13371\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-1.png\" alt=\"\" width=\"846\" height=\"267\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-1.png 846w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-1-300x95.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-1-768x242.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><\/p>\n<p>Rounded May to June as shown in the picture.<\/p>\n<p>&nbsp;<\/p>\n<h3>Trunc Function<\/h3>\n<p>Rounds the reference date value that we provide in the SQL Query according to the rounding degree value that we will give in our query.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>select TRUNC( to_date('20-May-2019'),'W') as \"Trunc Week\" from dual;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13372\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-1.png\" alt=\"\" width=\"811\" height=\"247\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-1.png 811w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-1-300x91.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-1-768x234.png 768w\" sizes=\"auto, (max-width: 811px) 100vw, 811px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>To_char with Dates<\/h3>\n<p>When using the date format,<\/p>\n<ul>\n<li>Must be single-quoted and case-sensitive.<\/li>\n<li>It must contain the current date format.<\/li>\n<li>The format component is separated by a comma from the date value.<\/li>\n<\/ul>\n<p><strong>Example:<\/strong><\/p>\n<pre>select first_name, to_char(birth_day, 'DD Month YYYY') BIRTH_DAY from Student;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-13373\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-1.png\" alt=\"\" width=\"852\" height=\"338\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-1.png 817w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-1-300x119.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-1-768x305.png 768w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Nvl Function<\/h3>\n<p>Used to convert values from null to another value in SQL Query result.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>select * from student;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13375\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_6.png\" alt=\"\" width=\"904\" height=\"240\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_6.png 904w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_6-300x80.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_6-768x204.png 768w\" sizes=\"auto, (max-width: 904px) 100vw, 904px\" \/><\/p>\n<p>&nbsp;<\/p>\n<pre>Select first_name,surname,NVL(CASH,0) from student;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13376\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_9.png\" alt=\"\" width=\"846\" height=\"381\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_9.png 846w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_9-300x135.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_9-768x346.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><\/p>\n<h3>AVG Function<\/h3>\n<p>It is used to average the given values.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>select first_name,last_name,salary from hr.employees;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13390\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-2.png\" alt=\"\" width=\"972\" height=\"626\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-2.png 972w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-2-300x193.png 300w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_3-2-768x495.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/p>\n<p>&nbsp;<\/p>\n<pre>select avg(salary) from HR.employees;\r\n\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-13391\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-2.png\" alt=\"\" width=\"862\" height=\"262\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-2.png 467w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_4-2-300x91.png 300w\" sizes=\"auto, (max-width: 862px) 100vw, 862px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Count Function<\/h3>\n<p>Used to find the number of rows in a table.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>select first_name from hr.employees;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-13392\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-2.png\" alt=\"\" width=\"769\" height=\"775\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-2.png 664w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-2-150x150.png 150w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_5-2-298x300.png 298w\" sizes=\"auto, (max-width: 769px) 100vw, 769px\" \/><\/p>\n<p>There&#8217;s more than 25 lines in the image. Let&#8217;s see how many records there are<\/p>\n<pre>select count(*) from hr.employees;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-13393\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_6-1.png\" alt=\"\" width=\"797\" height=\"318\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_6-1.png 421w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_6-1-300x120.png 300w\" sizes=\"auto, (max-width: 797px) 100vw, 797px\" \/><\/p>\n<h3>Max\/Min Function<\/h3>\n<p>Used to find the maximum \/ smallest equivalents of the given values.<\/p>\n<p><strong>Example: <\/strong><\/p>\n<pre>select max(salary) \"Max Salary\" from HR.employees;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-13394\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_9-1.png\" alt=\"\" width=\"834\" height=\"276\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_9-1.png 514w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_9-1-300x99.png 300w\" sizes=\"auto, (max-width: 834px) 100vw, 834px\" \/><\/p>\n<pre>select min(salary) \"Min Salary\" from HR.employees;\r\n\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-13395 alignnone\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_10.png\" alt=\"\" width=\"831\" height=\"305\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_10.png 455w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_10-300x110.png 300w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Sum Function<\/h3>\n<p>Used to find the sum of the values in the entered column.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre>select SUM(salary) \"Sum Salary\" from HR.employees;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-13396\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_11.png\" alt=\"\" width=\"797\" height=\"255\" srcset=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_11.png 553w, https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/12\/Screenshot_11-300x96.png 300w\" sizes=\"auto, (max-width: 797px) 100vw, 797px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>See you in the next article..<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone, in this tutorial we will look the Date functions.\u00a0 Date functions in SQL Language are given below. &nbsp; &nbsp; ADD_MONTHS Function Used to add months to the date value that you type as a result of the SQL query Example: select * from student where surname=&#8217;Federer&#8217;; select first_name,surname,Add_Months(birth_day,1)from student where surname=&#8217;Federer&#8217;; &nbsp; Months_Between &hellip;<\/p>\n","protected":false},"author":67,"featured_media":12330,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3019],"tags":[4936,4929,4875,4883,4873,4869,4910,1340,4870,4895,4905,4935,4926,4915,4921,4919,4920,4918,4917,3192,4872,4916,4928,4876,4912,4881,4880,4890,4867,3062,4879,4891,4923,4924,4922,4925,4909,4911,4877,4896,4908,4882,4884,4897,4901,4900,4898,4902,4903,4899,4871,3015,3018,4868,4904,4906,4893,4930,4934,4914,4933,4885,4887,4913,3000,4931,4889,4927,4907,4888,4886,4892,4874,4878,4894,4932],"class_list":["post-13346","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-oracle-sql","tag-case-insensetive","tag-create-view","tag-database-nedir","tag-insert-nedir","tag-kolay-sql","tag-mysql-sql","tag-or","tag-oracle-sql","tag-php-sql","tag-plsql","tag-right-outer-join","tag-selecting-multiple-colum","tag-sql-all-drop","tag-sql-all-statements","tag-sql-alter","tag-sql-alter-colum","tag-sql-alter-database","tag-sql-alter-statement","tag-sql-alter-table","tag-sql-and","tag-sql-baslangic-dersleri","tag-sql-creat-table","tag-sql-create-view","tag-sql-database","tag-sql-date-functions","tag-sql-dcl","tag-sql-ddl","tag-sql-delete","tag-sql-dersleri","tag-sql-distinct","tag-sql-dml","tag-sql-dml-nedir","tag-sql-drop-colum","tag-sql-drop-database","tag-sql-drop-statement","tag-sql-drop-table","tag-sql-filtering-data","tag-sql-functions","tag-sql-ifadeleri","tag-sql-ile-ne-yapilir","tag-sql-in-statement","tag-sql-insert","tag-sql-insert-nasil-yapilir","tag-sql-is-ilanlari","tag-sql-join-yapisi","tag-sql-kaynaklari","tag-sql-kullanmak","tag-sql-lef-join","tag-sql-left-outer-join","tag-sql-makaleleri","tag-sql-nasil-ogrenilir","tag-sql-nedir","tag-sql-ogrenme","tag-sql-ogrenmek","tag-sql-right-join","tag-sql-right-outer-join","tag-sql-select-islemi","tag-sql-set-auto-increment","tag-sql-sorting-results","tag-sql-subqueries","tag-sql-syntaxt-rule","tag-sql-tablo-olusturma","tag-sql-tablo-yapisi","tag-sql-to_char-function","tag-sql-tutorial","tag-sql-union-statement","tag-sql-update-islemi","tag-sql-view","tag-sql-where-statement","tag-sql-yapisi","tag-tablo-nedr","tag-tablodan-veri-cekmek","tag-temel-seviye-sql","tag-temel-seviyede-sql","tag-tsql","tag-union-table"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/ittutorial.org\/wp-content\/uploads\/2019\/11\/sql.png","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/users\/67"}],"replies":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/comments?post=13346"}],"version-history":[{"count":3,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13346\/revisions"}],"predecessor-version":[{"id":13397,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/13346\/revisions\/13397"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media\/12330"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=13346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=13346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=13346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}