Tampilkan postingan dengan label SQL. Tampilkan semua postingan
Tampilkan postingan dengan label SQL. Tampilkan semua postingan

Rabu, 24 November 2021

Top 5 Courses to Learn Microsoft SQL Server Database and Transact-SQL in 2022 - Best of Lot

Top 5 Courses to Learn Microsoft SQL Server Database and Transact-SQL in 2022 - Best of Lot

Hello guys, you might know that along with Oracle and MySQL, Microsoft SQL Server is one of the most popular relational databases in the tech world. It's used in many big organizations like Investment Banks, Insurance companies, and particularly at firms that use Microsoft technologies like Windows Server. With the growing popularity and market share of Microsoft Azure, there is a good chance that the demand for Microsoft SQL Server will also increase, particularly in the cloud. There is already a high demand for both Microsoft SQL Server DBA and Programmers who have SQL Server experience, and that's why it's an excellent decision to learn MSSQL in 2022.
Top 5 MySQL Courses for Programmers and DBAs to Learn Online in 2022 - Best Of Lost

Top 5 MySQL Courses for Programmers and DBAs to Learn Online in 2022 - Best Of Lost

Hello guys, if you are interested in learning SQL with MySQL database and looking for some awesome resources e.g. books, tutorials, and online courses then you have come to the right place. In past, I have shared some useful books and tutorials and in this article, I am going to talk about some of the best MySQL online courses from Udemy and Pluralsight which you can join to learn SQL and MySQL from the comfort of your office or home. In the last couple of years, you might have heard the statement that everybody should learn to code, which is great. Coding is now like reading, writing, and speaking skills and in today's Information technology-centric world it is a must-have and there is no better way to start coding than learning SQL, the most popular programming language.

Senin, 22 November 2021

Top 5 Courses to learn PostgreSQL Database in 2022 - Best of Lot

Top 5 Courses to learn PostgreSQL Database in 2022 - Best of Lot

PostgreSQL is one of the most popular databases after the big three - Oracle, SQL Server, and MySQL. PostgreSQL is commonly known as Postgres and is often referred to as the world's most advanced open source database. If you are looking to learn PostgreSQL in 2022 and looking for some useful resources like books, tutorials, and courses then you have come to the right place. In this article, I am going to share some of the best PostgreSQL online courses for beginners. These courses will cover topics ranging from installations to writing basic queries and retrieving data from tables. you will also explore the logic of SQL Joins, and a few best practices which are essential while working in a real-world, production PostgreSQL database.

Sabtu, 06 November 2021

What is Referential Integrity in Database or SQL - MySQL Example Tutorial

What is Referential Integrity in Database or SQL - MySQL Example Tutorial

Referential Integrity is a set of constraints applied to foreign keys which prevents entering a row in the child table (where you have the foreign key) for which you don't have any corresponding row in the parent table i.e. entering NULL or invalid foreign keys. Referential Integrity prevents your table from having incorrect or incomplete relationships e.g. If you have two tables Order and Customer where Customer is parent table with primary key customer_id and Order is child table with foreign key customer_id. Since as per business rules you can not have an Order without a Customer and this business rule can be implemented using referential integrity in SQL on a relational database.

Jumat, 29 Oktober 2021

How to Split String in SQL Server and Sybase? Example Tutorial

How to Split String in SQL Server and Sybase? Example Tutorial

Sometimes we need to split a long comma-separated String in a Stored procedure e.g. Sybase or SQL Server stored procedures. It's quite common to pass comma delimited or delimiter separated String as an input parameter to Stored procedure and then later split comma separated String into multiple values inside stored proc. This is not just the case of the input parameter but you can also have a comma-separated string in any table data. Unfortunately, there is no split() function in Sybase or SQL Server 2005 or 2008 which can directly split a string based on delimiter just like in the Java string split method

Selasa, 26 Oktober 2021

How to Find Duplicate values in SQL? GROUP BY and HAVING Query Example Tutorial

How to Find Duplicate values in SQL? GROUP BY and HAVING Query Example Tutorial

Hello guys, if you are wondering how to find duplicate values in a table then you can use the GROUP BY and HAVING clause in SQL. Using group by you can create groups and if your group has more than 1 element it means it's kind of duplicate. For example, you need to write a SQL query to find all duplicate emails in a table named Person. This is a popular SQL Query interview question as well as a Leetcode problem. You can see that email a@b.com is a duplicate email as it appears twice in the table. You need to write a query to find all duplicate values, I mean emails in this case. 

+----+---------+
| Id | Email   |
+----+---------+
| 1  | a@b.com |
| 2  | c@d.com |
| 3  | a@b.com |
+----+---------+

For example, your query should return the following for the above table:

+---------+
| Email   |
+---------+
| a@b.com |
+---------+

Note: All emails are in lowercase.

Jumat, 22 Oktober 2021

How to check for Null in SQL Query? IS NULL Example Tutorial

How to check for Null in SQL Query? IS NULL Example Tutorial

One of the most common SQL Interview questions on Programming interviews is to select some rows from a table that also contains null values. Since many SQL developers are used to using = and != operator on WHERE clause, they often tend to forget the fact that column allows NULL or not. Using = or != is perfectly fine if your column has NOT NULL constraint and you know for sure that there are no NULL values in that column, but it does contain NULLs then your SQL query will return the incorrect result at times. This is one of the most common mistakes but at the same time hard to find SQL bugs if it managed to get into the real environment. In this article, you will learn the right way to check NULL values in SQL queries using IS NULL and IS NOT NULL predicates.

Kamis, 21 Oktober 2021

How to Remove Leading/Trailing White Space from a String in SQL Server? LTRIM, RTRIM Example

How to Remove Leading/Trailing White Space from a String in SQL Server? LTRIM, RTRIM Example

Unlike Java, Microsoft SQL Server 2008, 2012, 2014,  and even the latest version don't have a built-in trim() function, which can remove both leading and trailing space from the given String. But, SQL Server does have two built-in functions LTRIM() and RTRIM() to remove leading and trailing space. The LTRIM() function removes space from the left side of String so you can use it to get rid of leading space, while RTRIM() removes white-space from the right side of String so you can use it to delete trailing space. You can even combine these two methods to create your own TRIM() method in SQL SERVER e.g. LTRIM(RTRIM(column)) will act as a TRIM() method because it removes both leading and trailing space.

Rabu, 20 Oktober 2021

Difference between CAST, CONVERT, and PARSE function in Microsoft SQL Server

Difference between CAST, CONVERT, and PARSE function in Microsoft SQL Server

Though all three, CAST, CONVERT, and PARSE are used to convert one data type into another in SQL Server, there are some subtle differences between them. The  CAST method accepts just two parameters, expression, and target type, but CONVERT() also takes a third parameter representing the format of conversion, which is supported for some conversions, like between character strings and date-time values. For example, CONVERT(DATE, '2/7/2015', 101) converts the character string '2/7/2015' to DATE using DATE format 101, representing United States standard.

Selasa, 19 Oktober 2021

Top 6 SQL Query Interview Questions for Programmers and Data Scientists - Best of Lot

Top 6 SQL Query Interview Questions for Programmers and Data Scientists - Best of Lot

SQL, a short form of Structured Query Language is one of the essential skills in today's programming world. No matter whether you are a Java developer, C++ developer or Python developer, you must know how to write SQL queries. Every programming job interview has at least one or two questions that require you to write SQL queries for a given requirement and many developers struggle there. It's easy to answer theoretical questions like what is the difference between clustered and non-clustered index (see) or what is the difference between correlated and non-correlated subqueries (see), but when it comes time to actually write SQL queries to solve problems, it's not that easy, especially if you haven't done your homework and practice.

Senin, 18 Oktober 2021

Top 5 Websites to Learn SQL Online for FREE - Best of Lot

Top 5 Websites to Learn SQL Online for FREE - Best of Lot

SQL is one of the most important skills for any programmer be it a Java, C++, Python, JavaScript, or Ruby developer. Almost 95% of the Java applications use a relational database in their back-end and almost all web applications use the database. In recent years, one of the most common ways to learn any programming skill is online, at your comfort of the office or home and SQL is no different. Learning SQL online has another advantage of a quick head start because you don't need to install a database and create tables to write some SELECT queries. The installation and setup are definitely a tough part for beginners and I have gone through that pain every time I have to learn a new database.

Jumat, 08 Oktober 2021

How to get just DATE or TIME from GETDATE() in SQL Sever - Example Tutorial

How to get just DATE or TIME from GETDATE() in SQL Sever - Example Tutorial

The GETDATE is one of the most popular built-in methods of  Microsoft SQL Server, but unlike its name suggests, it doesn't return just date, instead, it returns date with time information e.g. 2015-07-31 15:42:54.470, quite similar to our own java.util.Date from Java world. If you want just a date like 2015-07-31, or just a time like 15:42:54.470 then you need to either CAST or CONVERT output of GETDATE function into DATE or TIME data type. From SQL Server 2008 onward, apart from DATETIME, which is used to store both date and time, You also have a DATE data type to store data without time e.g. 2015-07-31, and a TIME data type to store time without any date information like 15:42:54.470.

Sabtu, 31 Juli 2021

Difference between LEFT and RIGHT OUTER Joins in SQL - MySQL Join example

Difference between LEFT and RIGHT OUTER Joins in SQL - MySQL Join example

There are two kinds of OUTER joins in SQL, LEFT OUTER join and RIGHT OUTER join. The main difference between RIGHT OUTER joins and LEFT OUTER join, as their name suggests, is the inclusion of non-matched rows. Sine INNER join only include matching rows, where the value of the joining column is the same, in the final result set, but OUTER join extends that functionality and also include unmatched rows in the final result. LEFT outer join includes unmatched rows from the table written on the left of the join predicate. 

Selasa, 27 Juli 2021

How to enclose a list of values into single quotes for SQL query? Microsoft Excel Example

How to enclose a list of values into single quotes for SQL query? Microsoft Excel Example

Many times you get a list of values that you want to check in the database to confirm if they exist in your tables or to get more information bout them. For example, you got a list of 100 stocks and you want to check their last day closing prices in the database. The problem arises when values to be searched are Strings e.g. VARCHAR or CHAR because VARCHAR values need to be enclosed in the single quotes in most of the database like SQL Server, Oracle, or MySQL. If a number of values are less than 5 then it makes sense to add single quotes around them and separate them by comma manually so that you can use them on IN clause of your SQL query, but if it's more than 5 like 50 or 100 then manually enclosing them into single quotes will take a lot of time and most importantly programmers are not supposed to do such silly stuff manually.
How to format Date and Time in SQL Server and Sybase? Examples

How to format Date and Time in SQL Server and Sybase? Examples

How to format a date in SQL Server like in the "yyyymmdd" format? Suppose you have a date and time column in Sybase or Microsoft SQL Server,  which is displaying values in "Dec  31, 2011, 12:00 AM" and you want to display it in any particular DATE format like YYYYMMDD or DDMMYYYY, how will you do that? This is also one thing you need to keep in mind when you convert a DATE, TIME, DATETIME column into CHAR or VARCHAR values.  It's easy to format dates using the convert function in Sybase or SQL Server, but it's slightly difficult to remember the cryptic formatting style codes that go with it. For example, using style code, 112 is used to format dates in the "YYYYMMDD" format e.g. "20170329".
What is difference between SQL, T-SQL and PL/SQL? Answer

What is difference between SQL, T-SQL and PL/SQL? Answer

Today, we are going to see another common and interesting SQL interview question, what is the difference between SQL, T-SQL, and PL/SQL? It is also one of the most common doubts among SQL beginners. It's common for programmers to think that why there are many types of SQL languages, why not just single SQL across DB? etc. Well, let's first understand the difference between SQL, T-SQL, and PL/SQL, and then we will understand the need for these dialects. SQL is standard for querying, inserting, and modifying data in a relational database. It is categorized into DDL and DML and is powerful enough to create database objects e.g. table, view, stored procedure, and can perform CRUD operation (SELECT, INSERT, UPDATE, and DELETE) query.