Same result with different SQL Query

 

SQL Challenge :- Same result with different SQL Query

SQL> create table plch_sessions
2  (session_id integer primary key,
3  title varchar2(50),
4  starting date,
5  duration interval day to second);

Table created.

SQL> insert into plch_sessions
2  values(101,’Analytics Explained’,to_date(‘2013-02-21 09:00:00′,’YYYY-MM-DD HH24:MI:SS’),INTERVAL ’60’ MINUTE);

1 row created.

SQL> insert into plch_sessions
2  values(201,’Bulk Operations’,to_date(‘2013-02-21 10:15:00′,’YYYY-MM-DD HH24:MI:SS’),INTERVAL ’45’ MINUTE);

1 row created.

SQL> insert into plch_sessions
2  values(102,’Analytic Use Cases’,to_date(‘2013-02-21 11:30:00′,’YYYY-MM-DD HH24:MI:SS’),INTERVAL ’60’ MINUTE);

1 row created.

SQL> insert into plch_sessions
2  values(301,’Midnight Werewolf’,to_date(‘2013-02-22 00:00:00′,’YYYY-MM-DD HH24:MI:SS’),INTERVAL ’30’ MINUTE);

1 row created.

SQL> insert into plch_sessions
2  values(202,’Exception Handling’,to_date(‘2013-02-22 09:00:00′,’YYYY-MM-DD HH24:MI:SS’),INTERVAL ’45’ MINUTE);

1 row created.

SQL> commit;

Commit complete.

SQL> select t.title from plch_sessions t
2  where trunc(t.starting) = date ‘2013-02-21′;

TITLE
————————————————–
Analytics Explained
Bulk Operations
Analytic Use Cases

SQL> select t.title from plch_sessions t
2  where trunc(t.starting,’D’) = date ‘2013-02-21′;

no rows selected

SQL> select t.title from plch_sessions t
2  where trunc(t.starting,’DD’) = date ‘2013-02-21’;

TITLE
————————————————–
Analytics Explained
Bulk Operations
Analytic Use Cases

SQL> select t.title from plch_sessions t
2  where t.starting between to_date(‘2013-02-21 00:00:00′,’YYYY:MM:DD HH24:MI:SS’) and
3  to_date(‘2013-02-21 23:59:59′,’YYYY:MM:DD HH24:MI:SS’);

TITLE
————————————————–
Analytics Explained
Bulk Operations
Analytic Use Cases

SQL> select t.title from plch_sessions t
2  where t.starting >= date ‘2013-02-21’
3  and t.starting < date ‘2013-02-21’ + interval ‘1’ day;

TITLE
————————————————–
Analytics Explained
Bulk Operations
Analytic Use Cases

SQL>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.