bareasfen.blogg.se

Adventureworks database practice problems
Adventureworks database practice problems












adventureworks database practice problems

The records are stored in to table according to the rowid of the table. Select * from Student where rowid = select max(rowid) from Student This is also most common SQL Practice Exercises with Solutions where user needs to fetch the last record from the table, The SQL Like special character is most used wildcard to fetch data with specific condition in the table.Įxample 12 :How to fetch last record from Student table. Select * from Students where name like ‘P%’ and surname like ‘S%’

adventureworks database practice problems

The Like operator will help to achieve this, The example is pretty simple where user needs to use the Set operators from SQL.Here user needs to use union set operator.Įxample 11 : List the Students whose name starts with P and surname starts with S. This is bit tricky question.We can not use the 2 aggregate functions together.

#ADVENTUREWORKS DATABASE PRACTICE PROBLEMS HOW TO#

These are above some SQL Practice Exercises with Solutions which are highly used in real life scenarios.In out SQL Practice Exercises with Solutions we are using the Regular expression function named REGEXP_LIKE to check for Email validation.įOR ANY SQL SUPPORT CONTACT : 10 : How to fetch maximum salary of Employee and minimum salary of Employee together from Employee table. User needs to use regular expression function to check the Email validation with single query. Here we are using lpad() function to fetch dollar symbol.Įxample 9 :How to check for Email is correct or wrong with using single query. SELECT lpad (‘$’, ROWNUM,’$’) FROM Employee WHERE ROWNUM <4 We need to use Employee table with data more than 4 to perform this. We can not use dual table to perform this operation. Here we are using the operator from SQL to delete duplicate rows from the table.Įxample 8 : How user can display following structure with using single SQL Query. (Select max (rowid) from Employee b where Employee_num=b.Employee_num) There are situations where user needs to find out the duplicate rows as well as delete those rows. Using above query we find out the duplicate record count from the table.

adventureworks database practice problems

You need to use order by clause as well.Įxample 7 : How to delete duplicate rows from the table.

adventureworks database practice problems

In this example we need to use the Count function as well as group by and having. There are some situations where user needs to fetch some last records from the table.The following query will fetch the last records from the table. The condition 1=2 means True=False which is always False condition.So with using the above query user can create duplicate table structure without data.Įxample 3 : How to display Last 10 records from Student table. The above query will create the same table as student named ‘Student_Replica’ without data.It is possible due to the condition 1=2. Let us consider that user wants to create a replica of table named ‘Student’ without having data. Example 2 : How to create table with same structure without data? The above query will create the same table as student named ‘Student_Replica’ with its data. Let us consider that user wants to create a replica of table named ‘Student’.Ĭreate table Student_Replica as Select * from Student Important Queries for SQL Practice Exercises with Solutions : Example 1 : How to create table with same structure with data? I have already written article on real world industry examples of SQL.I want to add some queries from that article also.There are following SQL Practice Exercises with Solutions which are mostly used in day to day life in world of programming. In my previous article i have given the different examples of SQL as well as most important complex sql queries for interview purpose.I would like to combine all those examples and want to make one best article on SQL Practice Exercises with solutions.My main purpose writing this article on SQL Practice Exercises with solution is to get idea about different SQL real world examples as well as user can easily implement it in day to day life.These are the scenarios which are useful for real world industry.














Adventureworks database practice problems