Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Monday 18 November 2013

Sql Programing

Programming in SQL Server




Program 1.

 

begin 
 
print ' welcome to SQL Programming ‘
print ' SQL Server ‘ 

 
end


Program 2.

 

begin

declare @a int
declare @b int
declare @c int

set @a=67
set @b = 99
set @c=@a+@b

print @a
print @b
print@c

 print ' first program '

end


Program 3.

 

declare

@p int,@n decimal(5,2),@r decimal(5,2), @si decimal(7,2)

begin

set @p=10000
set @n=15
set @r=7.5
set @si=(@p*@n*@r)/100

print ' simple interest : ' + convert(varchar,@si)

end


 Program 4.

 

declare

@a int,@b int,@c int

begin

set @a=50
set @b=120
set @c=35

if @a>@b and @a>@c

print ' a is big'

else if @b>@c

print ' b is big'

else

print ' c is big'

end

 Program 5.

 

declare

@a int

begin

set @a=1

while (@a<=5)

begin

print @a

set @a=@a+1

end

 


Tuesday 12 November 2013

SQL Select Command

SQL STATEMENT


SELECT Statement

The SELECT statement is used to select data from a database.
The result is stored in a result table, called the result-set.

 Syntax -

SELECT column_name(s)
FROM table_name
and
SELECT * FROM table_name
 Note: SQL is not case sensitive. SELECT is the same as select.

 SELECT DISTINCT Statement


In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.
The DISTINCT keyword can be used to return only distinct (different) values.

 Syntax -

SELECT DISTINCT column_name(s)
FROM table_name

The WHERE Clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.

Syntax -

SELECT column_name(s)
FROM table_name
WHERE column_name operator value

The ORDER BY Keyword

The ORDER BY keyword is used to sort the result-set by a specified column.
The ORDER BY keyword sort the records in ascending order by default.
If you want to sort the records in a descending order, you can use the DESC keyword.

 Syntax -

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC



Monday 11 November 2013

SQL

 SQL?

SQL  stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database. Some common relational database management systems that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system. However, the standard SQL commands such as "Select", "Insert", "Update", "Delete", "Create", and "Drop" can be used to accomplish almost everything that one needs to do with a database. This tutorial will provide you with the instruction on the basics of each of these commands as well as allow you to put them to practice using the SQL Interpreter.

 SQL queries

The SQL queries are the most common and essential SQL operations. Via an SQL query, one can search the database for the information needed. SQL queries are executed with the “SELECT” statement. An SQL query can be more specific, with the help of several clauses:
  • FROM - it indicates the table where the search will be made.
  • WHERE - it's used to define the rows, in which the search will be carried. All rows, for which the WHERE clause is not true, will be excluded.
  • ORDER BY - this is the only way to sort the results in SQL. Otherwise, they will be returned in a random order.  
 Simple Exampl Of SQL  Sql Example

Artificial Intelligence (AI)

  Artificial Intelligence (AI) The Power and Potential of Artificial Intelligence Artificial Intelligence (AI) is revolutionizing the world ...