Tuesday, August 24, 2010

Important Facts about Sql

Hi friends,
I am going to introduce some facts about sql commands hope you all will like it.

1) have you tried the command insert into ashu(max(id)+1,'deepu');
i tried it to insert id(last max(id)+1) automatically in serial order.but it fails.guess why??
because insert statement does not take group function in insert statement.

2)CASE – similar to IF/THEN/ELSE – used to turn Rows into Columns
Syntax –
SELECT a,b,c,
CASE WHEN(condition) THEN action ELSE action
FROM table_name
COALESCE – similar to IFNULL – returns first Non-NULL value in a list of values
Syntax – COALESCE (value1,value2)

EXTRACT – can be used to Extract Date parts –
Syntax - EXTRACT(month FROM date_field) or SUBSTR in Oracle

UNION and UNION ALL
Beware that UNION ALL is usually required –
because UNION implies a DISTINCT that does not return all the qualifying records.

Avoid Dividing by Zero – use NULLIF


2) what is the use of dual in sql? plz post your answers.i will be posting its answer with in some weeks(;-))

No comments:

Post a Comment