Skip to main content

Group By and Having clause

 Group By and Having The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each dept". The GROUP BY statement is must be used with aggregate functions (COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or more columns. GROUP BY Syntax

SQL DML, DML and DQL commands

 SQL DML, DML and DQL commands




1. DDL(Data Definition Language) : DDL or Data Definition Language really comprises of the SQL orders that can be utilized to characterize the information base diagram. It just arrangements with portrayals of the information base pattern and is utilized to make and adjust the structure of data set articles in the data set. 

Instances of DDL orders: 

SQL DML, DML and DQL commands



○ CREATE –is utilized to make the information base or its articles (like table, file, work, sees, store system and triggers). 

○ DROP –is utilized to erase objects from the information base. 

○ ALTER-is utilized to adjust the structure of the information base. 

○ TRUNCATE–is utilized to eliminate all records from a table, including all spaces dispensed for the records are taken out. 

○ COMMENT –is utilized to add remarks to the information word reference. 

○ RENAME –is utilized to rename an item existing in the information base. 

2. DQL (Data Query Language) : 

DML proclamations are utilized for performing questions on the information inside pattern objects. The motivation behind DQL Command is to get some blueprint connection dependent on the inquiry passed to it. 

Illustration of DQL: 

○ SELECT –is utilized to recover information from the an information base. 







3. DML(Data Manipulation Language) : The SQL orders that manages the control of information present in the information base have a place with DML or Data Manipulation Language and this incorporates the majority of the SQL explanations. 

Instances of DML: 




○ INSERT –is utilized to embed information into a table. 

○ UPDATE –is utilized to refresh existing information inside a table. 

○ DELETE –is utilized to erase records from an information base table. 





Comments

Popular posts from this blog

How to convert null value to decimal in SQL Server?

 How to convert null value to decimal in SQL Server? While writing the sql queries s most issue coming when no value available in table and some calculation needs to perform. in following scenario salary value is null but it needs to display in same format like wise other value appearing in table for salary. First we need to handle the null value. select empid,empname,dept, isnull(salary,0) as salary from k4coding_emp if require further conversion then use following command to convert the value. select empid,empname,dept,  cast(isnull(salary,0) as decimal(18,2)) as salary from k4coding_emp

Sql-Keywords (distinct , order by) and where clause

 Sql-Keywords (distinct , order by) and where clause Distinct Keyword The DISTINCT keyword is used to return only distinct (unique) column values. Sql tables often contains many duplicate values in columns and sometimes you only want to list the unique(distinct) values. sample table : In table we can multiple name with same values. to view on distinct column value following distinct command to execute Select distinct empname from k4coding_emp Distinct Keyword: The ORDER BY keyword is used to sort the  output  in ascending or descending order. ORDER BY Syntax SELECT col1, col2,col3, ... FROM tablename ORDER BY col1, col2, ... ASC|DESC; The ORDER BY keyword sorts the records in ascending order by default.  Select * from k4coding_emp order by empname To sort the records in descending order, use the DESC keyword. Select * from k4coding_emp order by empname desc Where Clause: The SQL WHERE clause is used to filter the records, it contains logical conditions . The WHERE cl...

SQL JOIN | SQL JOINS | SQL JOINS with Examples | SQL JOIN TABLES | SQL JOINS TUTORIAL

 SQL JOINS SQL Joins basically used for mapping the data from more than 1  tables. For correct out output we need to map correct respective columns. Following example will demonstrate how to use sql joins TYPES of SQL JOINS: followings are joins type in sql 1.Inner Join 2.Left Join  3.RIght Join 4.Full outer Join Table setup for Join example. Create Table CityMaster_k4Coding ( id bigint identity(1,1), CityName varchar(100) ) Create Table StudentMaster_k4Coding (  STudentName Varchar(100),  Standard varchar(100),  Admissiondate datetime , Cityid bigint ) Insert Into cityMaster_k4coding  values  ( 'MUMBAI' ) -- auto id 1 Insert Into cityMaster_k4coding   values  ( 'DELHI' ) -- auto id 2 Insert Into cityMaster_k4coding   values  ( 'PUNE' ) -- auto id 3 Insert Into   cityMaster_k4coding   values  ( 'CHENNAI' ) -- auto id 4 Insert Into    StudentMaster_k4Coding  values ( 'ASHISH','X' ,ge...