‎2007 May 23 9:30 AM
Hi experts,
I have doubt regarding select statement.
1)If i use SELECT * FROM <DBTAB>
All the columns are selected
My doubt is all the lines of the <DBTAB> are selected or not?
2)If i use SELECT DISTINCT * FROM <DBTAB>
all the lines and all columns of <DBTAB> are selected or not?
Then if i remove DISTINCT addition in the above statement what is the result?
‎2007 May 23 9:36 AM
answers:
1) select * from tab
all the lines are selected.
number of the lines selected is equal to the number of entries present in the table no matter if the entries are repeated or not.
2) select distinct * from tab.
here also, all the lines are selected, but duplicate entries are selected only once.
if there are two or more similar entries, only once it will be selected.
thanks,
viji.
‎2007 May 23 9:32 AM
Hi,
you will get the same result i.e all columns are selected.
2)If i use SELECT DISTINCT * FROM <DBTAB>
gives the same result because there are no duplicates in a database table.
‎2007 May 23 9:34 AM
Hi
In the first case it will select all the entries from all fields in the table..Means you will get a clear replica of your table in your internal table...Select Distinct you can restrict table entries accordingly...If you are removing the Distinct addition the same thing will happen as of No.1....
Reward All Helpfull Answers.........
‎2007 May 23 9:35 AM
Hi,
1.All the lines are selected from the Database in the First Statement.
2.Ths Select Distinct is used to exclude Duplcate Entries.
Regards,
Padmam.
‎2007 May 23 9:36 AM
answers:
1) select * from tab
all the lines are selected.
number of the lines selected is equal to the number of entries present in the table no matter if the entries are repeated or not.
2) select distinct * from tab.
here also, all the lines are selected, but duplicate entries are selected only once.
if there are two or more similar entries, only once it will be selected.
thanks,
viji.
‎2007 May 23 9:37 AM
Hi Surya,
1. The number of lines selected from database table depends on the conditions provided in the WHERE clause. If nothing is mentioned, then all records are fetched.
2. If you say select DISTINCT for a field, all the records for different values for that field are selected. If you remove this DISTINCT, then you get multiple records for the same value of the field.
Regards,
Raj
‎2007 May 23 9:43 AM
Hi Surya,
Select * from dbase table will select all records from the data base based on the where condition given.
When we use Distict
SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.
If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:
If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW
If the system tries to access pool or cluster tables and single columns are specified in columns.
Regards
Sarath
‎2007 May 23 9:45 AM
Hi Surya,
If you use SELECT * FROM <DBTAB> all the lines of the <DBTAB> are selected.
If you use SELECT DISTINCT * FROM <DBTAB> duplicates will not be selected.
that means if some data is repeated it will not show the data twice.
ex: if 21 is there 2 times it will show only one time
‎2007 May 23 9:52 AM
Hi,
1> Select * selects all the columns as well as rows from <DBTAB>.
2>Select DISTINCT fetches unique records .but it is normally followed by a where clause.
eg..I wish to retrive the DISTINCT "cities'" from EMP table..THe same city might be repeated for employees..but it will fetch the different cities with none repeated.
Reward points if helpful.
Dev
‎2007 May 23 9:52 AM
Hi,
1. All lines of DBtab will be selected unless condition specified in where clause.
2. With distinct * clause it will show distinct RECORD, with only * it will give all records.
Jogdand M B
‎2007 May 23 10:15 AM
Hi Surya,
1.Ths Select Distinct show only single value , remove duplicate entries.
2.All the lines are selected from the Database in the First Statement.