Search This Blog

Thursday, September 27, 2012

How can create new column by query that column not in table:


How can create new column by query that column not in table:
We have one table test in this table 2 columns
Sno, name I want 3rd columns for ues then we have create 3rd column by query and also fixed that column value “0”.

select sno,name,'0' as amount from test

Out put:
sno
name
amount
1        
cp       
0
2        
ram      
0
3        
jon      
0

Understand diffrence between 1st and 2nd query:

select sno,name,sno as amount from test

Output:
sno
name
amount
1        
cp       
1        
2        
ram      
2        
3        
jon      
3        

No comments :