GeekInterview.com
Series: Subject: Topic:

SQL Interview Questions

Showing Questions 1 - 20 of 216 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

Get numeric values only using SQL ?

Asked By: sateesh44 | Asked On: Nov 24th, 2011

I have table with one column. Type varchar.. phone --------------- 99samn44423m44 8034skdf3453a2 909090abc4567d i want to get numeric values.. I mean my output will be phone --------------- 994442344 80343453a2 9090904567 thanks in advance.. sateesh

Answered by: pradipta on: Jul 28th, 2014

SELECT REGEXP_REPLACE(COL_NAME, ([a-z]|[A-Z]), ) FROM TBL_NAME ;

Answered by: stalinK on: Jul 23rd, 2014

Code
  1. DECLARE @Temp VARCHAR(100)=(STA123LIN)
  2. Declare @NumRange AS varchar(50) = %[0-9]%
  3.     While PatIndex(@NumRange, @Temp) > 0
  4.         SET @Temp = Stuff(@Temp, PatIndex(@NumRange, @Temp), 1, )
  5.  
  6. SELECT @Temp

What is the difference between SQL and SQL server?

Asked By: priyank singh pathania | Asked On: Sep 26th, 2005

Not known

Answered by: ramesh on: Jul 24th, 2014

Sql is a language and sql server is database

Answered by: ADINARAYANA REDDY on: Apr 12th, 2014

Sql is language and sql server is database like RDBMS,ORACLE

Difference between varchar and varchar2?

Asked By: Sreyas | Asked On: Feb 23rd, 2006

Star Read Best Answer

Editorial / Best Answer

Answered by: Ranjeet

Answered On : Feb 27th, 2006

Emp_name varchar(10) -  if you enter value less than 10 then remaining space can not be deleted. it used total 10 spaces.

Emp_name varchar2(10) - if you enter value less than 10 then remaining space is automatically deleted

Answered by: manojkumarkadiyala on: Jul 10th, 2014

Varchar is nothing but fixed length character data size min1 to max 2000
varchar2 is nothing but variable character data size min 1 to max 4000

Answered by: Ravi on: Jul 13th, 2012

Varchar & Varchar2 both having the same size, & working as same.
Bt the main diff is varchar is an ANSI Datatype & Varchar2 is the Oracle datatype.

One SQL statement which produces the following output

Asked By: sashelp | Asked On: May 20th, 2013

Department_id ,emp_count, dept_percentage

Answered by: VIBHAV MISHRA on: Jun 30th, 2014

Update

SQL query

Asked By: venkateshm | Asked On: Feb 18th, 2014

What is SQL query to retrieve the second effective employees from job data for all the employees?

Answered by: VIBHAV MISHRA on: Jun 30th, 2014

Select max(Sal) from Emp Where Sal not in(Select max(Sal) from Emp)

How select query works in Oracle

Asked By: SaratKumar | Asked On: Oct 10th, 2005

When we give select * from emp; how does Oracle respond?

Answered by: Rakesh on: Jun 29th, 2014

Check for syntax correct Then it will check weather the table is present or not in database is nothing but a Parsing
fetch the data

Answered by: sainath on: Sep 24th, 2012

Syntax verification done from client only not in the server only valid sequel statements are send to the server if syntax is not correct client throws error

How to retrieve a second highest salary from a table?

Asked By: BJMallinatha | Asked On: Jun 21st, 2012

How to retrieve a second highest salary from a table? note:suppose salaries are in duplicate values eg: name sal malli 60000 pandi 60000 rudra 45000 ravi 45000

Answered by: jyotirmaya mohanty on: Apr 11th, 2014

Fetching Nth Highest Salary:

Code
  1. SELECT * FROM Products P1
  2. WHERE (N-1) = (
  3. SELECT COUNT(P2.Price)
  4. FROM Products P2
  5. WHERE P2.Price > P1.Price);

Answered by: Navneet Verma on: Mar 27th, 2014

Select max(Sal) from Emp Where Sal not in(Select max(Sal) from Emp)

Is it possible to create user without using (create user) command ?

Asked By: dineshkrishnamca | Asked On: May 9th, 2011

Answered by: sekarh on: Apr 2nd, 2014

Yes

Answered by: smonroy on: Sep 27th, 2011

If you want is not created a user with command line, you should create it with the interface

Corelated query

Asked By: vivekvinayy | Asked On: Oct 26th, 2012

What is difference b/w coreleated subquery and nested subquery?

Answered by: pradeep on: Nov 21st, 2013

A outer query out put is input of inner query

Answered by: Vikas on: Jul 31st, 2013

Co-related sub query give reference to outer main query but nested sub query will have independent result set to be passed to outer query.

What is the real mean of foreign key?

Asked By: Rajat Pathak | Asked On: Sep 13th, 2013

Answered by: Aria Ansari on: Nov 12th, 2013

It is about referential integrity or making data both reliable and Secure. As an example by applying a foreign key constrain between customer and order tables It will not be allowed to create an order...

How to find the employee who get seventh largest salary in the company?

Asked By: mithrz | Asked On: Aug 19th, 2012

Answered by: dinesh on: Jul 23rd, 2013

Code
  1.  SQL>SELECT DISTINCT SAL FROM EMP E WHERE 7>=(SELECT COUNT (DISTINCT SAL) FROM EMP A WHERE A.SAL>=E.SAL) ORDER BY SAL DESC

Answered by: Amninder on: Apr 15th, 2013

Select emp_id,emp_name,salary from employee a, (Select salary,dense_Rank() over (order by salary DESC) rank_sal from employee)b where a.salary=b.salary and rank_sal=7; The Inline Query will orde...

Dml operations on base tables using a simple view

Asked By: hari.plsql | Asked On: Jan 25th, 2013

Can we make dml operations on base tables using a simple view?Can we insert or update or delete rows to the base tables using a view?

Answered by: lviswanath on: Jul 22nd, 2013

Of course we can do anything i.e. updating/deleting/inserting on a base table underlying a simple view, until unless its covering NOT NULL columns of the table in the query of the simple View.

Answered by: ppad001 on: Feb 27th, 2013

Yes we can use DML operations on single table view.

What is difference between DBMS and RDBMS?

Asked By: krishnamoorthy | Asked On: May 15th, 2006

Answered by: pradip on: May 26th, 2013

The primary difference between the DBMS and RDBMS we can add the foreign keys for relating the tables In dbms ,relation is between two files . while in rdbms relation is made between two tables. rdbms...

Answered by: parth on: Jan 28th, 2013

Dbms does not support client/server architecture and rdbms supports client/server architecture.

Normalization in SQL

Asked By: robindas | Asked On: Jan 16th, 2013

Explain the normalization and why it is done. Explain the case when we avoid the normalization in database.

Answered by: ppad001 on: Feb 27th, 2013

For perfomance optimization.
Like in case of datawarehousing operation the no of tables to be joined to get the desired output might be too high. In such a case we de-normalize to serve our purpose.

How to rename or change table name in SQL?

Asked By: shojol | Asked On: Mar 30th, 2012

Answered by: shikha on: Feb 3rd, 2013

Sp_RENAME old_table_name, new_table_name

Answered by: Gunjan David on: May 13th, 2012

SQL >> rename table_name1 to new_table_name;

What are steps to follow for query tuning ?

Asked By: thoufik | Asked On: Oct 27th, 2011

Answered by: robindas on: Jan 11th, 2013

Few steps for query tuning. 1) Check for if any sub query or exists or not exists is there if yes then try to change it in the joins 2) Try to check the way joins had been written try to put it in f...

Answered by: samareshoracle on: Aug 4th, 2012

Following a Tuning Methodology Objectives:: • Determine performance problems • Manage performance • Describe tuning methodologies • Identify goals for tuning • Describe automatic SQL tunin...

Difference between joins and subquery?

Asked By: Ratan satish | Asked On: Dec 6th, 2012

Why do we use joins, instead subquery has same operation?

Answered by: robindas on: Jan 11th, 2013

The subquery scan the complete table to apply so its slow whether joins are much faster.

Answered by: Koonal saxena on: Dec 20th, 2012

Joins are performance killer

SQL query to change lower case in a table to upper case

Asked By: venkat2604 | Asked On: Nov 29th, 2012

In a table the persons name is in lower case "abc" and is there any SQL query to obtain that persons name as "abc" as an output?

Answered by: Muzeeb on: Jan 6th, 2013

Yes, using SQL UPPER function.

Code
  1. SELECT UPPER(name) FROM TABLE;

State true or false. !=, <>, ^= all denote the same operation.

Asked By: Interview Candidate | Asked On: Mar 6th, 2005

True

Answered by: Guru on: Dec 19th, 2012

True

Answered by: Durgesh Kumar Singore on: Feb 7th, 2012

In SQL 2005 only != and operator perform same operation

^= does not work

Difference between cluster and non-cluster index?

Asked By: bsush | Asked On: Oct 17th, 2006

Star Read Best Answer

Editorial / Best Answer

Answered by: Sushant

Answered On : Oct 25th, 2006

The difference is that, Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.

Answered by: Sameer on: Nov 1st, 2012

Now SQL SERVER 2008 onwards we can have 1 cluster index and 999 non cluster index on one table.

Answered by: primarykey2000 on: Apr 22nd, 2008

clustered index  - the index order matches the order of physically stored data.cluster index can be used on table that doent get changes frequentlyusing DML statement on cluster index column have...

First | Prev | | Next | Last Page

 

 

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.