How to select Distinct columns from the table, table having
20 columns and i want all coulmns

Answers were Sorted based on User's Feedback



How to select Distinct columns from the table, table having 20 columns and i want all coulmns..

Answer / amit

select distinct * from table_name

Is This Answer Correct ?    18 Yes 7 No

How to select Distinct columns from the table, table having 20 columns and i want all coulmns..

Answer / latha.s

select distinct * from tablename;

Is This Answer Correct ?    6 Yes 1 No

How to select Distinct columns from the table, table having 20 columns and i want all coulmns..

Answer / ram

select * from tablename
select distinct * from tablename
above two select statements give same output with all
column name and also data
if we want only column name & its details(datatype,sizre)
use

select * from
information_schema.columns where table_name='EMP1'
(or)
select distinct * from
information_schema.columns where table_name='EMP1'

(Here Table name mustbe in single quotes and also capital
letters only)
here also both select statements output is same

Is This Answer Correct ?    0 Yes 0 No

How to select Distinct columns from the table, table having 20 columns and i want all coulmns..

Answer / saleem

select *from tablename gives all distinct columns in the
table

Is This Answer Correct ?    1 Yes 2 No

How to select Distinct columns from the table, table having 20 columns and i want all coulmns..

Answer / monal

To select distinct columns you can mention them in the SQL
query and to select all columns you can use select * from
information_schema.columns

Is This Answer Correct ?    2 Yes 8 No

Post New Answer

More SQL Server Interview Questions

What is index?

1 Answers   Cap Gemini,


can any one say how to update the following senario I have a table <srabank> in which the table structure is as follows ANAME ACCNO LOCATION ACCTYPE BAL SBanuPrakash 31518746291 Punganur deposit 4000 Sreenivas 31518746292 mahoobnagar current 14000 Ranjith 31518746293 Karimnagar Savings 2000 Giresh 31518746294 Chennai deposit 40000 Boo 31518746295 Chennai Savings 20000 Jay 31518746296 Valachari Savings 1000 tirumalraj 31518746297 Vellore Savings 8000 The senario is We need to select one account number and check the balance after checking the balance if the balance exist we need to transfer to another account . in the from account the amount need to be reduced and in the to account the amount needed to be added. for example for the <accountno> <31518746291> the balance is <4000> for the <accno> <31518746292> the balance is <14000> after transferring the balance the details will look as follows <accno><31518746291> <bal> <2000> <accno><31518746292> <bal> <16000> the above mentioned two statment will come under the final result.

3 Answers  


Do you know what is bit data type and whats the information that can be stored inside a bit column?

0 Answers  


I have a huge amount of data which is displayed in a report. The data is viewed every day. Every day the data is displayed in 30 secs but suddenly today it is giving an timeout message today. Data has not been changed. The situation is same as yesterday. What might be the reason??? Please Answer.

4 Answers   Satyam,


What's the purpose of Stored Procedure?

6 Answers   Wipro,


Mention the differences between substr and charindex in sql server.

0 Answers  


Can group by and orderby be used together?

0 Answers  


This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?

0 Answers   TCS,


What are the differences between local and global temporary tables?

0 Answers  


how many instance use in sql server 2005

4 Answers   EFI, HCL,


What does indexation mean?

0 Answers  


what types of replication are supported in sql server? : Sql server database administration

0 Answers  


Categories