Home » SQL & PL/SQL » SQL & PL/SQL » Ask a question
Ask a question [message #356033] Wed, 29 October 2008 02:07 Go to next message
haifeng1984
Messages: 3
Registered: October 2008
Junior Member
I have a table like this:

name height weight
Sharon 62.5 112.5
Tammy 62.8 102.5
Alfred 69 112.5
Duke 63.5 102.5
Guido 67 133
James 57.3 83
Jeffrey 62.5 84

now I only need to check the distinct height value of 62.5 ,how to write the sql statement ?

select distinct a.height, b.name
from sasuser.class a right join sasuser.class b
on a.name=b.name;
can't help.
Re: Ask a question [message #356035 is a reply to message #356033] Wed, 29 October 2008 02:12 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@haifeng1984,

Add a WHERE Clause to your SQL Statement if you meant to fiter out the records.
Hope this helps. http://img2.mysmiley.net/imgs/smile/innocent/innocent0002.gif

Regards,
Jo
Re: Ask a question [message #356039 is a reply to message #356033] Wed, 29 October 2008 02:38 Go to previous messageGo to next message
haifeng1984
Messages: 3
Registered: October 2008
Junior Member
@joicejohn,
sorry, I haven't made it clear.
I mean select distinct height value.
Still like to thank you, But this way the where statement can't work , I have tried.
Re: Ask a question [message #356042 is a reply to message #356033] Wed, 29 October 2008 02:52 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
Quote:
I mean select distinct height value.

Sorry, but it is not clearer. Could you post the desired result with explaining rule for choosing/not choosing the output row(s)?

Also, please, format the result, as recommended in http://www.orafaq.com/forum/t/88153/0/, section "How to format your post?".
Re: Ask a question [message #356043 is a reply to message #356039] Wed, 29 October 2008 02:52 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why WHERE should not work?

please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Post a test case: create table and insert statements along with the result you want with these data.

Regards
Michel
Re: Ask a question [message #356044 is a reply to message #356033] Wed, 29 October 2008 02:53 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Great topic title. It really indicates what your problem is about.

Show us your required output and use [code] and [/code] tags to keep it readable.

[Edit: hmm.. several people beat me to that..]

[Updated on: Wed, 29 October 2008 02:53]

Report message to a moderator

Re: Ask a question [message #356064 is a reply to message #356033] Wed, 29 October 2008 04:51 Go to previous messageGo to next message
haifeng1984
Messages: 3
Registered: October 2008
Junior Member
Thanks everone!
The expected output is:

name height weight
Sharon 62.5 112.5
Tammy 62.8 102.5
Alfred 69 112.5
Duke 63.5 102.5
Guido 67 133
James 57.3 83

attention:there is no "Jeffrey 62.5 84"

Pls do it in one statement.
Re: Ask a question [message #356066 is a reply to message #356064] Wed, 29 October 2008 05:02 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
The expected output is:

Why?

Michel Cadot wrote on Wed, 29 October 2008 08:52
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Post a test case: create table and insert statements along with the result you want with these data.

Regards
Michel


Re: Ask a question [message #356073 is a reply to message #356033] Wed, 29 October 2008 06:18 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
Quote:
attention:there is no "Jeffrey 62.5 84"

Why Jeffrey? Why did you not omit Sharon?
Quote:
Also, please, format the result, as recommended in http://www.orafaq.com/forum/t/88153/0/, section "How to format your post?".
Re: Ask a question [message #356077 is a reply to message #356073] Wed, 29 October 2008 06:53 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
[off topic]

Sharon?!? Would YOU omit Sharon? I wouldn't! ./fa/917/0/

[/off topic]
Re: Ask a question [message #356078 is a reply to message #356077] Wed, 29 October 2008 06:58 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Littlefoot wrote on Wed, 29 October 2008 12:53
[off topic]

Sharon?!? Would YOU omit Sharon? I wouldn't! ./fa/917/0/

[/off topic]

At 62.5 cm and 112.5 kg?

I would!
Re: Ask a question [message #356081 is a reply to message #356033] Wed, 29 October 2008 07:31 Go to previous message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
Quote:
At 62.5 cm and 112.5 kg?

Only original poster knows the units used, but I would bet they are 62.5 inches (159 cm) and 112.5 pounds (51 kg). Looks much better...

However I would let Jeffrey with Alfred, Duke, Guido, James, ... and put Sharon off the list Nod .
Previous Topic: Paging to show limited number of records
Next Topic: Group consecutive records
Goto Forum:
  


Current Time: Sun Dec 11 04:29:21 CST 2016

Total time taken to generate the page: 0.06355 seconds