Hey Guys, I hope that you are enjoying with my blogs writing and today's we will cover some "SQL SERVER" Concepts.
Microsoft SQL Server is a relational database management system, or RDBMS, developed and marketed by Microsoft.
As a database server, it is a software products with primary function of storing and retrieving data as requested by other software application.
Initial Releases is April 24, 1989;
SQL UNION OPERATOR:
- The union operator is used to combine the result-set of two or more select statements.
- Every select statements within union have the same number of columns
- The columns also have similar data type
- The columns in every select statement must also be in the same order
- Syntax:
- For Distinct Contents:
For Example:
Input:
- For All Contents:
For Example: Input
select Id, FirstName, LastName from tblCustomer1
union all
select Id, FirstName, LastName from tblexpired
select 'nomal' as type1, Id, FirstName, LastName from tblCustomer1
union all
select 'expired' as type1,Id, FirstName, LastName from tblexpired
- GROUP BY:
- This statement is often used with aggregate function(COUNT(),MAX(), MIN(),SUM,AVG()).
- For Example: we have created a table "tblCustomer_ctry" by using this aggregate function we will find its sum of sales of two Countries.
- "tblCustomer_ctry"
group by country
SUBQUERY: A subquery is a query within another SQL query and embedded within WHERE clause.
- It is also called Nested Query.
- In this case firstly executes its inside queries and after that outside queries.
- Above two table has created tblCustomer and tblAddress .
where CustomerId_fk in
(select Id from tblCustomer)
Input: select * from tblAddress
where CustomerId_fk in
(select Id from tblCustomer where Id=CustomerId_fk)
Thank You...
ليست هناك تعليقات:
إرسال تعليق