Вы находитесь на странице: 1из 3

SQL fiddle

http://sqlfiddle.com/ website provides a real time working environments of Database like Oracle,
Sql server, MySQL, postgreSQL and more. Sql skill is important and basics skill in IT world.
To learn the Databases, we need to have the database in our own machine because, learning Sql is not
like studying theoretical subject. It involves more practical knowledge. Nowadays, we are working on
various Databases parallel and we cant install all Databases in our machine. Facing and rectifying the
Technical problem is also another headache. Considering this Sql fiddle.com is a boon to the Sql
knowledge seekers.
How to work?
Simple, once you clicked in the Sql fiddle.com link, you are directly taken to the working page. You
dont need to register too.
First thing, you have to do is choose the Database you want to work with using the Top dropdown
and create the schema object in the left side box (Fig SCHEMA WINDOW). Say, if you want to work
with tables use create table command (Create table customer (custid int, custname varchar (50)) with all
columns in related Database syntax and insert the values into the table. Once you done with it click the
Build schema at bottom.

In your right hand side box (Fig QUERY WINDOW), Query the tables which you create (select *
from customer ;) and click Run SQL Button. The result will display in the bottom (Fig RESULT
WINDOW). You can use all functions like Arithmetic, aggregate, etc. and also all types of joins.


Try to solve some below stuff in Sql server 2008/2012:
Question 1:
Select 1 Where 'hello'=Null
Union
Select 2 Where 'hello'<>Null
Union
Select 3 Where 'hello' Is Null
Union
Select 4 where 'hello' Is Not Null
Union
Select 5 Where Not ('hello'=Null)

Answer: 4 is correct
Magic trick:
Run SET ANSI _NULLS OFF command before running the Query. See the changes in the result.
Question 2:
ABC mart is a major retail mart in town. ABC retail mart has sales tables in their Database which is
updated at the end of day with total sales amount of the day.
Problem:
ABC retail mart needs Data for each day of month which sales amount values aggregate up to the Day
1 value. Say, In Day 1, sales amount is 10000. In Day 2, sales amount is 20000. Result to display is, 1-
10000, 2-30000 (sum of sales amount day 2 to day 1).
Workout with below table:
http://sqlfiddle.com/#!6/49892/2
Expected answer:
SALE_DATE SALES_AMT
01-04-14 10000 sum of Day 1 sales amount (10000)
02-04-14 50000 sum of Day 1,2 Sales amount (10000+40000)
10-04-14 60000 sum of Day 1,2,10 Sales amount (10000+40000+10000)
16-04-14 110000 .. and so on
25-04-14 160000
28-04-14 230000
30-04-14 290000

Answer:
http://sqlfiddle.com/#!6/49892/1/0