One SQL statement which produces the following output
Department_id ,emp_count, dept_percentage
How to find the employee who get seventh largest salary in the company?
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...
select salary data only
Dml operations on base tables using a simple view
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?
Yes we can use DML operations on single table view.
Explain the normalization and why it is done. Explain the case when we avoid the normalization in database.
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?
sp_RENAME old_table_name, new_table_name
SQL >> rename table_name1 to new_table_name;
What is difference between DBMS and RDBMS?
dbms does not support client/server architecture and rdbms supports client/server architecture.
Eg for DBMS is FoxPro,IMS... For RDBMS is SQL,ORACLE...
What are steps to follow for query tuning ?
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...
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?
Why do we use joins, instead subquery has same operation?
The subquery scan the complete table to apply so its slow whether joins are much faster.
Joins are performance killer
SQL query to change lower case in a table to upper case
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?
Yes, using SQL UPPER function.
Code
SELECT UPPER(name) FROM TABLE;
State true or false. !=, <>, ^= all denote the same operation.
True
True
In SQL 2005 only != and <> operator perform same operation
^= does not work
Difference between cluster and non-cluster index?
Answered by: Sushant
Answered On : Oct 25th, 2006The 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.
now SQL SERVER 2008 onwards we can have 1 cluster index and 999 non cluster index on one table.
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...
What is difference b/w coreleated subquery and nested subquery?
Can we call a function containing dml statements in a select query?
Only SELECT statement can be used in Functions. INSERT,UPDATE,DELETE are used.
How select query works in Oracle
When we give select * from emp; how does Oracle respond?
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
It will fetch all the data from employee table..then u give a select * command..
What is the difference between SQL and SQL server?
Not known
sql is a language
sql server is a RDBMS relational database management system.
Sql Server is a (RDBMS) Relation Database Management System where as SQL is Structure Query Language.
Get numeric values only using SQL ?
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
"sql declare @temp_numeric table (value nvarchar(500)) declare @i int=1,@len int,@ans nvarchar(100)=,@str nvarchar(100) DECLARE @count INT SELECT VALUE INTO #temp FROM dbo.numer...
Code
SELECT REPLACE(TRANSLATE(LOWER(99sAmn44423mz44),abcdefghijklmnopqrstuvwxyz, ), ,) FROM dual
How to retrieve a second highest salary from a table?
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
Select Max(Salary) from Emp Where Salary < (Select Max(Salary) from Emp)
select max(salary) from EmpTable where salary not in (select max(salary) from EmpTable));
How write a SQL statement to query the result set and display row as columns and columns as row?
How write a SQL statement to query the result set and display row as columns and columns as row?
The simplest way to implement this in SQL 2000/OracleSelect * from table1Create a temp table with No of columns = No of rows in table 1No of rows = No of columns in table 1and insert the data into the temp table using a loop logic.
Difference between varchar and varchar2?
Answered by: muralidhar_batta
View all answers by muralidhar_batta
Member Since Feb-2006 | Answered On : Feb 26th, 2006
varchar means fixed length character data(size) ie., min size-1 and max-2000
where as varchar2 means variable length character data ie., min-1 to max-4000
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.
Varchar - If we declare datatype as varchar then it will occupy space for null values. It can store upto 2000 bytes of character.
Varchar2 - If we declare datatype as varchar2, it will not occupy any space. It can store 4000 bytes of character.
Thanx,
I have following table as books101 book_no book_name author_name cost category1234 c dennis 450 system1235 Oracle loni 550 database1236 sql loni 250 database1237 PL/SQL scott 750 database now I want to list all the authors and book name that has more then 1 book written by them.Pls help
select AUTHOR_NAME,BOOK_NAME from books101
where AUTHOR_NAME in
(select author_name from books101 group by author_name having count(*)>1);
select book_name,author_name,count(*) from books
group by book_name,author_name
having count(*)>1