Thursday 19 May 2016

Tricky sql interview questions and answer

Guys generally we see that interviewer asked very easy question but question is very tricky. Even questions are very easy but bit difficult to give the answer. Here I am sharing a collection of tricky sql interview question.
1.       What will be the output of Select $
Answer: 0.0

Remember that only $ special character sql is returning the value for other special character it will giving error.
  
2.       What will be the Output of 
Select Count (*)


A count by definition has to return a value, so our query implicitly has one row in it. The result of the count is returning 1. SQL Server is effectively applying a form to a dummy table, which has only one row. Thus you will get 1 for your count. It is similar to DUAL table in Oracle, SYSDUMMY1 in DB2.
3.       What will be the Output of the below sql script
Select Count (‘88’)
Select Count (88)

Both are returning 1.


4.       What will the output of
Select (select ‘Bagesh’)
  
If select statement is in () then it will be treated as derived table.
  
5.       What will the output of the below sql script

Select Select ‘Bagesh’
  
If select statement is in () then it will be treated as derived table. If there is no () it will throw syntax error

6.       What will be the out of the below sql script.
Select Sum (1+4*5)



Select Max(1+4*5)



Select Max(‘Bagesh’)



7.       What will the output of below sql script
Select 1 + NULL


If we add anything on NULL the all value will be NULL. Suppose if we have null value then we need to replace null value to some other value and then we will do any operation. With the help of ISNULL () we replace the null value.
  
Above example I replace null value to 0.

8.       What will the output of below sql script
Select Case when NULL=NULL
Then ‘Yes’ else ‘No’ end as Result

Because two null value never same.


9.       What will the output of below sql script
Select top 2 1 ‘3’
  
3 will the column name and 1 is the value.
  
Syntax of top clause [Top 2] and the 1 is value and [‘3’] as column name
Same sql script we will write like
Select top 2 1 as ‘3’

10.   How to insert 100 records in a table without using loop.

Insert into Emp (ID,Name) values (1,’Bagesh kumar singh’)
Go 100
  
11.    For 9/2 I want the result as 4.5 write the sql script
For getting the desirer output first we need to convert the number to float.
  

12.   How we find the number of character occurs in a string for example in Bagesh Kumar Singh how many ‘a’ character occurs.


Read More tricky sql  interviews questions and answer: Click here 
https://www.deskbright.com/sql/sql-interview-questions/

55 comments:

  1. Replies
    1. Hi Bru,


      Great info! I recently came across your blog and have been reading along.
      I thought I would leave my first comment. I don’t know what to say except that I have


      I wanted to know if we should go for SQL Always-on AG or FCI for SharePoint environment. We are planning to host the whole SharePoint environment in Azure IaaS.
      what are the pros and cons of SQL Always-on AG and FCI in Azure Iaas for SharePoint.
      I read multiple articles and watched many videos about how to use this tool - and was still confused! Your instructions were easy to understand and made the process simple.


      Thanks,

      Delete
  2. Great collection of question and answers thank you for sharing. Follow the link if you want OBIEE Online Training

    ReplyDelete
  3. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating. Power Bi Online Training

    ReplyDelete
  4. useful this blog.Thanks for sharing this blog.
    MSBI Training in Hyderabad

    ReplyDelete

  5. Nice blog..! I really loved reading through this article... Thanks for sharing such an amazing post with us and keep blogging...
    data science online training
    best data science online training
    data science online training in Hyderabad
    data science online training in india

    ReplyDelete
  6. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful .MSBI Training Institutes in Bangalore

    ReplyDelete
  7. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    best servicenow online training

    ReplyDelete

  8. Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing on Msbi online training
    Msbi online training Hyderabad
    Msbi online training India
    Msbi online course
    Msbi course
    Msbi training
    Msbi certification training

    ReplyDelete
  9. Amazing & Great informative blog,it gives very useful practical information to developer like me. oracle training in chennai

    ReplyDelete
  10. Amazing & Great informative blog,it gives very useful practical information to developer like me. oracle training in chennai

    ReplyDelete
  11. Very nice informative blog. Actually it's great article. Thanks for sharing unique content. oracle training in chennai

    ReplyDelete
  12. very special. easy to understand…. taking things from root .. stay blessed
    We have an excellent IT courses training institute in Hyderabad. We are offering a number of courses that are very trendy in the IT industry. For further information.
    msbi course
    msbi developer course
    MSBI Certification Training

    ReplyDelete
  13. very special. easy to understand…. taking things from root .. stay blessed
    We have an excellent IT courses training institute in Hyderabad. We are offering a number of courses that are very trendy in the IT industry. For further information.
    msbi course
    msbi developer course
    MSBI Certification Training

    ReplyDelete
  14. very special. easy to understand…. taking things from root .. stay blessed
    We have an excellent IT courses training institute in Hyderabad. We are offering a number of courses that are very trendy in the IT industry. For further information.
    msbi course
    msbi developer course
    MSBI Certification Training

    ReplyDelete
  15. wonderful article contains lot of valuable information. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    This article resolved my all queries.good luck an best wishes to the team members.learn digital marketing use these following link
    Digital Marketing Course in Chennai

    ReplyDelete
  16. Learn Oracle DBA for making your career towards a sky-high with Infycle Technologies. Infycle Technologies provides the top Oracle DBA Training in Chennai and offering programs in Oracle such as Oracle PL/SQL, Oracle Programming, etc., in the 200% hands-on practical training with professional specialists in the field. In addition to that, the interviews will be arranged for the candidates to set their careers without any struggle. Of all that, Cen percent placement assurance will be given here. To have the best job for your life, call 7502633633 to Infycle Technologies and grab a free demo to know more.

    Infycle Technologies
    #85, Medavakkam Main Rd, Rajendra Nagar, Keelkattalai, Chennai, Tamil Nadu 600091.
    No.1 Oracle DBA Training in Chennai | Infycle Technologies

    ReplyDelete
  17. Sharing the same interest, Infycle feels so happy to share our detailed information about all these courses with you all! Do check them out
    Best Data training in chennai & get to know everything you want to about software trainings.

    ReplyDelete
  18. I am happy & satisfied to read this blog, because I have currently enrolled into SQL Certification. Thank you for you whole information.

    ReplyDelete
  19. Reach to the best <a href="https://infycletechnologies.com/python-training-in-chennai'>Python Training institute in Chennai</a> for skyrocketing your career, Infycle Technologies. It is the best Software Training & Placement institute in and around Chennai, that also gives the best placement training for personality tests, interview preparation, and mock interviews for leveling up the candidate's grades to a professional level.

    ReplyDelete
  20. Infycle Technologies, the top software training institute and placement center in Chennai offers the Best Digital Marketing Course in Chennai | Infycle Technologies for freshers, students, and tech professionals at the best offers. In addition to Digital Marketing, other in-demand courses such as DevOps, Data Science, Python, Selenium, Big Data, Java, Power BI, Oracle will also be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.

    ReplyDelete
  21. Infycle Technologies offers couples for care and technology in addition to Python Training in Chennai, 100% of the internship class will be prepared. After completing the training, the participants will be sent to the upper MNCs interviews. Call 750633333 to get more information and get a free display.

    ReplyDelete
  22. hello sir, I'm looking for sql and ssis training. Do you provide training?

    ReplyDelete
  23. Hi, I have read a lot from this blog thank you for sharing this information. We provide all the essential topics in Data Science Course In Chennai like, Full stack Developer, Python, AI and Machine Learning, Tableau, etc. for more information just log in to our website :
    https://skillslash.com/data-science-course-in-chennai
    https://skillslash.com/web-development-course-in-chennai
    https://skillslash.com/web-development-course-in-pune
    https://skillslash.com/web-development-course-in-bangalore
    https://skillslash.com/web-development-course-in-hyderabad

    ReplyDelete
  24. Thanks for giving this sort of nice information to all of us and please keep us updated in future also.I want to share some information about the Data Structures For best career in Data Structure And Algorithms Join skillslash it is best online platform For learning Data structures And algorithms Courses for more information go through website links down :
    https://skillslash.com/best-data-structures-algorithms-course
    https://skillslash.com/system-design-course
    https://skillslash.com/best-dsa-course

    ReplyDelete

If you have any doubt, please let me know.

Popular Posts