HomeОбразованиеRelated VideosMore From: kudvenkat

Select statement in sql server - Part 10

1044 ratings | 346707 views
In this video we will learn 1. Select specific or all columns 2. Distinct rows 3. Filtering with where clause. 4. Wild Cards in SQL Server 5. Joining multiple conditions using AND and OR operators 6. Sorting rows using order by 7. Selecting top n or top n percentage of rows Text version of the video http://csharp-video-tutorials.blogspot.com/2012/08/select-statement-part-10.html Slides http://csharp-video-tutorials.blogspot.com/2013/08/part-10-all-about-select.html All SQL Server Text Articles http://csharp-video-tutorials.blogspot.com/p/free-sql-server-video-tutorials-for.html All SQL Server Slides http://csharp-video-tutorials.blogspot.com/p/sql-server.html All Dot Net and SQL Server Tutorials in English https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd All Dot Net and SQL Server Tutorials in Arabic https://www.youtube.com/c/KudvenkatArabic/playlists
Html code for embedding videos on your blog
Text Comments (102)
Akash Mehra (15 days ago)
Please recheck, its Josh and John that is why order by age is inactive in the scenario. Would the name have been same then the age would have displayed in ascending manner. Its okay it was a human error.
REKHA KUMARI (2 months ago)
I saw a few videos and really liked the way you have explained it. It would be really helpful if you could also help us with real-time interview questions.
kudvenkat (1 month ago)
Hello Rekha - You can find a few SQL Server interview questions in the following playlist. https://www.youtube.com/playlist?list=PL6n9fhu94yhXcztdLO7i6mdyaegC8CJwR
REKHA KUMARI (2 months ago)
How many hours will it take to complete the " SQL Server tutorials for the beginners"?
kudvenkat (1 month ago)
Hi Rekha - Around 27 hours. I can confidently say if you are comfortable with the concepts discussed in these videos you will be able to achieve most of the things in SQL with a lot of ease.
M "or" S "or" T*
selim reza (2 months ago)
great sir....
Mahendranadh S (3 months ago)
Very Helpful Video !!! Helped me to learn well for the examination. Thank You !!!
ever movie (3 months ago)
Brindha Ganesan (4 months ago)
What a wonderful service you are doing to the community! You make things sound easy!!!!!
green heacker (4 months ago)
Really good video!! I hope it will help to all sql learner. you can also vesit this website.thank you!! https://tunesmk.blogspot.com/2018/10/sql-select-statement-tutorial-tunesmk.html
prateek shetty (5 months ago)
mumbai spelling :)
Sanjit Patil (5 months ago)
were can i get this database, i mean .bak file?
Ashish Akshantal (6 months ago)
How can we add multiple records for same column ? I mean, if we have a new column that we created in our table that has 13 records , and now how to add the values for the new column in all the rows ?
Raj Dora (6 months ago)
Hi, Can you please give examples for selecting values using date fields
pramod maurya (6 months ago)
Thanks a lot sir for your knowledge sharing.. thanks
Diesel Boats (8 months ago)
Simple. Thank you!
തമാശ (9 months ago)
For Simple SQL Tutorials : https://youtu.be/u96o6Asnm0M
Hi Venkat , By using IN operator we can able to get Records at time multiple Integer columns values. But What about character columns. I m not able to get the character columns (varchar data type columns) When I am going using IN Operator. If we have an any another operator, Plzzzz clarify me.
Trzbne (1 year ago)
Crystal clear again. Thank you very much! WE: You are the best teacher ever! YOU: Is that possible? WE: Absolutely!
siddhi chotaliya (1 year ago)
Hi Friends,  There is no mistake in result  BUT example was incorrect . Example should be something like this, if two person has same name i.e. JOSH one with age 24 and another with age 27. Name column is sorted in DESC order and age is in ASC order then JOSH with age 24 will get first priority and THEN JOSH with age 27 will come (Name DESC order and AGE is in ASC order). If there is same name then it will look for age in ASC order.
Danescu Ionut (1 year ago)
min 18:35 josh is not repeted twice ...there are josh and john (age desc is irrelevant)
jamal alaioud (1 year ago)
thank you
Scott Saccenti (1 year ago)
Learned more in this 21 minute video than you can get in 400-page books
Dear Sir, nobody can explain SQL better than you in this world. I have highest regards for you for ever
Gita Padhihari (1 year ago)
Thank You Sir. :)
indu sekhar k (1 year ago)
Bro use this query for joining two conditions instead writing or ... select * from person2 where city in('london','DC') and age>30
Bradley Brutus (1 year ago)
Man is this helpful!
Muhammad Shifa (1 year ago)
Hi sir how can we select all table name from database through querry?
Ab S (1 year ago)
Awesome as usual!
swati kamath (2 years ago)
Hi Venkat, Thank you for posting such amazing videos. I have a small doubt though, When we specify any character in the [ ] are they case sensitive?
Dev Expost (1 year ago)
For starters, it depends on how your db server was set up in the Server Properties, General, Server Collation. If you have a scheme like "SQL_Latin1_General_CP1_CI_AS" then it is: (CP1) Code Page 1252 characters, and searches are Case Insensitive and Accent Sensitive.
aswathi chandran (2 years ago)
Venkat, Your videos are awesome. Thank you so much. Can you pleses upload all the ppts alone somewhere. This will help us a quick recap day before interview. Going through all videos just before interview is not possible. Thanks
Ravali Sidam (1 year ago)
this is very very helpful.I appreciate your effort..God bless you
kudvenkat (2 years ago)
Hello Dear Aswathi, The image version of the slides are available on my blog at no cost. http://csharp-video-tutorials.blogspot.com However, if you want to download all the original PPTs, you can order them from the following link. Hope you will find them useful. http://www.pragimtech.com/download_kudvenkat_slides.aspx Goof Luck Venkat
Karuna Patel (2 years ago)
i am new to learning sql and want to get into BI. this is really helpful.
Karuna Patel (2 years ago)
simply awsome!! love the way you make it simple and explain very well. wish you have videos on SSIS, SSRS and Tableau.
yombo mahomet (2 years ago)
thanks for this tutorial
vijaya lakshmi (2 years ago)
hi venkat, u have done a great job thanks for the vedios. can u send me the download link of the database you used for the vedio's. it would be more helpfull for me
Gautam Thakur (2 years ago)
thank you
Tzvik Rabinowitz (2 years ago)
Hello Venkat. Thanks for your videos they are great!!!
Tzvik Rabinowitz (2 years ago)
Hello Venkat., I've notice you said something on using order by so that you can you use it on more than one column, i.e. name desc,age asc. but in the example I saw there was different input so I am not sure it truly explained I mean to the part close to the end in the 18th min. aprox. What do you think?
John E Marchán Jr (2 years ago)
I agree that the problem was that the names were not the same. One was Josh, and the other was John. therefore the age field didn't matter.
Piyasi Dey (2 years ago)
Drago (2 years ago)
I think he meant it like, that you can order items by more arguments. For instance, first you order them by NAME, but, if there are more items with same name, than they will be ordered by second argument, in this case AGE... I hope we are speaking about same thing :)
Piyasi Dey (2 years ago)
his videos are really help full..but yes...I was confused too..
TheReedm5 (2 years ago)
Venkat, you and your videos are fabulous my friend!!!!! Simply awesome.
Henrique Cardoso (2 years ago)
Nice video but at 16:44 you typed "Mumbai" wrong, leading it to only show the people from London
Mohiuddin excel (3 years ago)
brother what if i want to display two perticular person's detail ? for example select * from table where name = MILLER , SMITH ...... HELPE ME OUT BROTHER :)
Mohiuddin excel (2 years ago)
thanxxx brother u wa helpfull (y)
Soumya Banerjee (2 years ago)
+Mohiuddin excel select * from table where name in ('MILLER','SMITH')
Georgi Georgiev (3 years ago)
You had Mumbai typed wrong, my Indian friend :D
Holla Bummer (3 years ago)
At 15:04 I think it is important to note that the only reason why he was able to use this SQL code: Select * from tblPerson Where Name LIKE [MST%] to select the people whose name start with M, S, or T is because the names in the Name column in tblPerson all start with a **SINGLE** capital letter. So if either capital M, S , or T is in the name then it will be selected. But for example if you had a name like bMSTj (Completely made up name :)) then that query would still Select this name since the character list MST is present in bMSTj.
Imran Asif (3 years ago)
Awesome short video. Everything I needed for daily small tasks.
Infector88 (3 years ago)
Hello Venkat. Your tutorials are awesome, keep up the good work! But I would like to point a small mistake; when you are talking about sorting asc and desc, there is JOSH and JOHN, not Josh x2. Following that, "age asc" is not applied in this particular example, since we don't have any of the names repeated.
Ben Parker (2 years ago)
Thanks for that, was watching in small window and just took him saying that the names were the same for granted and couldn't figure out why the 29 was above the 20 if they were supposedly in ascending order.
Rakinroww (3 years ago)
is that possible? absolutely! well with your manner of telling everything is possible ;p great tutorials thanks
Ankaj Jha (3 years ago)
Dear Sir, I want Retrieve Even or Odd number from table *** HOW ??? Please provide me solution for the question thanks
phani raj (1 year ago)
Select * from MyTable where MyNumberColumn % 2 = 0
Pixelated Network (3 years ago)
+Ankaj Jha Here is a solution for even: Select * from MyTable where MyNumberColumn % 2 == 0 here is for odd: Select * from MyTable where MyNumberColumn % 2 == 1 MyTable is the table you want to select from, and MyNumberColumn is the column with numbers, from which you want to filter either odd or even numbers. Hope it helped
DHANUSH KUMAR R (3 years ago)
what is the role of tsql in sequel server
Bhupinder pal singh (3 years ago)
+DHANUSH KUMAR R .........tsql is the language for talking to SQL server ....just like hindi or english is the language we understand .....to talk to sql server we have tsql
Pranay (3 years ago)
Hello Venkat, I have a question in this part 10 video you have given an example where we can sort on two columns. I don't think so this will work if we look into the output. I think practically its not possible?. Could you please confirm on this? Thanks in Advance.
Dheeshanie Rajarathna (3 years ago)
Hi Vankut, Thank you very much!!!
Tech Talks (3 years ago)
Awesome! channel, I need your help. I have a web form that surfaces data based on a phone number from my Microsoft SQL DB 2008. I would like for people to have to put their first name in and their phone number before any data surfaces on the screen??? Please help or suggest a resource...
Hi Vankut, You are simply awesome. Your ways of presentation connect to anyone with little or no knowledge of the technology you are teaching. I wish you all the best for your continuous support to the beginners like me. God bless you. :)
Hi Venkat, I have a doubt here. Could u tell me... among order by and top (say top 10) which one has the priority. I mean will the rows be ordered first and then top 10 are picked up. Or will top 10 be picked up and then ordered. Imagine the data in table is in disordered randomly.
Mehmet Yener Yilmaz (4 years ago)
18:25 are you sure that age ascending order sorted correctly ? :S
Parm Singh (1 year ago)
it's not a mistake because he sort the name desc order and that last 2 name is start with J but the next letter is different like JOSH and JOHN
Om Prakash (1 year ago)
Mehmet Yener Yilmaz you are right it's mistake at 18:32
p v (2 years ago)
Ya... Its not. He said josh is repeated twice and the age is given in ascending, but it is not it is josh and john which are two different names. Before adding age ascending and after the result is same.
Holla Bummer (3 years ago)
http://stackoverflow.com/questions/2051162/sql-multiple-column-ordering Check out the link above but the accepted answer Ignacio Vazquez-Abrams says: Select * from tblPerson order by Name DESC, Age ASC:  Sorts everything by Name (descending) first, and then by column2 (ascending) whenever the Name fields for two rows are equal.
LukkyLuke80 (4 years ago)
17 min in the video u misspell mumbai...
Santos (4 years ago)
Michael Taye (4 years ago)
Nice !!!
PJB (4 years ago)
Hi saw ur video part 10 as that is the only thing i needed to lear right now and want to say thank you so very much. It was very helpful.
Chhaya Mehta (4 years ago)
nice and  thanks 
Mithilesh thakur (4 years ago)
how to find the 2nd largest age of a person
kudvenkat (4 years ago)
Good question. This video should help.  Part 1 How to find nth highest salary in sql
Heema Bhatt (4 years ago)
thanks for sharing this videos. its really helpful but please include another interview question explanation: how to fetch 2nd highest age from table? its really tricky one... 
Nika Javakhishvili (4 years ago)
the greatest teacher ever. these video series are better than read books
Lars Rye Jeppesen (4 years ago)
Thank you very much, these tutorials are brilliant.
Radovan Slavkovský (5 years ago)
Hey Venkat, I am taking this lessons of yours / 10th of 68 atm / and I ´ve feel I should say thanks for all these lessons..  Very nice of you that you made it free of charge.. and with this all support of yours.  Sending best regards from Slovakia, 
kudvenkat (5 years ago)
Thank you very much for taking time to give feedback. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video. For email alerts, when new videos are uploaded, you may subscribe to my channel.
ZABI (5 years ago)
Very helpful tutorials.
Geanta C. Constantin (5 years ago)
the best ever tutorial ;)
kudvenkat (5 years ago)
In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you.
Javier Vara (5 years ago)
HI. I've unable to follow the tutorials starting at Part 10. The tutorial is great but there is no way I can get to continue. Any suggestions?
Sayed ubaidh (5 years ago)
Hi Venkat, I have a question in DISTINCT. Here is how my table looks like[ID Name City] [1 ubaidh pune] [2 hajra Mumbai ] [3 Misbah Goa] [4 pune pune] Now if i fire this query "select distinct name,city from table1" i get the following result [hajra Mumbai] [Misbah Goa] [pune pune] [ubaidh pune]. But in the video you said that DISTINCT on multiple columns will give value distinct across the 2 columns but in the 3rd record you can see i have [pune pune] in both columns. Can u please explain
Marco Geraldes (5 years ago)
First of all, great videos, very usefuls and very well organizeds. Keep on make this good work. But this one in particular you have a bug on the AND OR operators. You have city='Mumabi' instead of Mumbai and the table as only one record with age > 25 so that particular query allways return only one row.
shashi kant (5 years ago)
Please tell how to insert records into a table from multiple tables
kudvenkat (5 years ago)
Hi Rajiv, if you have the rows matching with what you have in the where clause, then you should get data. Can you please share your query and the data in one or two rows of your table that you are querying. Without looking at the table and the query I wouldn't be able to tell what's wrong. Good Luck.
Rajiv Lamichhane (5 years ago)
Dear sir, query got executed successfully but data hasn't came, couldn't figure it out...
kudvenkat (5 years ago)
Hi Rajiv, escape the single quote with another single quote. So, your query will be something like this - Select * from TableName where ColumnName in ('40'' Standard Dry','20'' Standard Dry'). Hope this helps. If you want to receive email alerts, when new videos are uploaded, please feel free to subscribe to my youtube channel. May I ask you for a favour. I want these tutorials to be helpful for as many people as possible. Please share with your friends and family.
Rajiv Lamichhane (5 years ago)
Dear sir, how could we give in command if the data type is something like 20' standard dry or any data has a ' sign? for example i gave one command like this, select * from shipment data where container type name in (40' Standard Dry, 20' Standard Dry) will not be executed while i tried... please help me
Ameya Gaikwad (5 years ago)
Thanks for your time and efforts in creating such videos. Your teaching style is really amazing. I'm a oracle programming but wanted to Learn SQL Server. This learning by doing and examples makes it much easier. Once I complete this SQL Server tutorial, I'm looking forward to get into your .net tutorial which I'm sure would be a wonderful resource for a .net beginner like me.
Anoj Shrestha (5 years ago)
Hello Venkat...Thanks for the great video tutorial series..I like your way of teaching...really I became your follower..I am practicing your all video tutorials step by step..waiting for your more tutorials ...once again thanks lots for your very great and useful tutorials....keep it up :)
carelesshx (5 years ago)
Hi Venkat! Thanks very much for these videos, they're really helpful. Just thought it was worth mentioning that using the != operator in a query doesn't return NULL values in the selected column. It appears that NULLs require special handling in SQL and I hope this gets covered in a future video :)
Tomasz Malesa (6 years ago)
Hi, great job! but funny mistake @18:20. I wondered why this AGE column isn't realy in ASC order like You said. The answer is: there aren't Josh and Josh but Josh and John, it takes me some time to realize it :)
suman s (6 years ago)
Brilliant..!! Thanks Venkat Very Helpfull :)
sumanhappy (6 years ago)
Hi Venkat, Real big thanks for videos they are really helpful. can you cover examples on selection the 2ND highest salary from tables using triggers and also concatenating the date according to persons date of birth i.e. (if we enter person's DOB,The present age of the person with days should be returned )
Jstar141957 (6 years ago)
Thanks for the instructions, I needed that!

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.