Skip to main content

Posts

Showing posts with the label SQL Server CASE compares

17 Best Differences Between Cassandra And MongoDB [How To]

Stayed Informed – Best Apache Cassandra Tutorials with Examples Cassandra Database:- 1.       The Cassandra is the leading NoSQL , distributed database management system. 2.       Developed by Apache Software Foundation and the Initial release were 2008. 3.       Cassandra is an Open Source. 4.       The idea is based on wide column store of BigTable and DynamoDB . 5.       Its extensible record stores and also store data in records with an ability to hold very large numbers of dynamic columns. 6.       It’s Implementation using Java language. 7.       It’s using Server operating systems like BSD, Linux, OS X, and Windows. 8.       Its schema free and secondary indexes restricted . 9.       The APIs and other methods access by proprie...

T-SQL Columns, Tables Alias

In SQL, we can alias columns, views and tables. A table alias is also called a co-relation name. It is a temporarily names of columns or tables. The Alias temporarily assigns another name to a column, or table at the time of a SELECT query and the assigning alias doesn’t rename the column or table name actually! Basically, it make column, or table more readable to the programmers. Syntax: --USE OF TABLE ALIAS SELECT TBL . Id , TBL . Name FROM [dbo].[Tbl_Demo] AS TBL WHERE TBL . Id in ( 1 , 2 , 3 ) --USE OF COLUMN ALIAS SELECT TBL . Id AS UID, TBL . Name AS UNAME FROM [dbo].[Tbl_Demo] AS TBL WHERE TBL . Id in ( 1 , 2 , 3 )

T-SQL CASE Expressions

The CASE expressions compare an expression to a set of simple expressions to determine the result and CASE can be used in any statement that allows a valid expression. It is IF-THEN-ELSE statement. Syntax: For a simple CASE expression CASE COLL WHEN 1 THEN 'One' WHEN 2 THEN 'Two' WHEN 3 THEN 'Three' ELSE 'None' END AS COLL_Name -- CREATE TABLE CREATE TABLE [dbo].[Tbl_Demo]( [ID] [ int ] IDENTITY( 1 , 1 ) NOT NULL , [Name] [ varchar ]( 500 ) NULL , [Age] [ int ] NULL , [IsActive] [ bit ] NULL , [IsDeleted] [ bit ] NULL , CONSTRAINT [PK_Tbl_Demo] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO --INSERT TABLE ROWS SET IDENTITY_INSERT [dbo].[Tbl_Demo] ON GO INSERT [dbo].[Tbl_Demo] ([ID], [Name], [Age], [IsA...