Hi everybody,
I would like to select all "id" in a table ONLY where "raff" is distinct.
I think it shoult be such a thing:
SELECT id FROM mytable WHERE (SELECT DISTINCT raff) or
SELECT id FROM (SELECT DISTINCT raff FROM mytable)
So what is the correct syntax
Thnak U
BaRRonThis sounds familiar
select id = max(id)
from tbl
group by raff
having count(*) = 1
Showing posts with label mytable. Show all posts
Showing posts with label mytable. Show all posts
Sunday, March 25, 2012
Thursday, March 22, 2012
Distinct Command ...
mytable
Cat1
Cat2
Cat3
Start price
End price
A
a
a
12
21
A
a
b
98
11
A
a
a
99
12
A
b
b
12
11
A
b
a
9
0
A
b
b
1
1
…
…
…
…
…
…
…
…
…
…
My result should be like this …..
( Result of SQL Query? )
Cat1
Cat2
Cat3
A
a
a
A
a
b
A
b
a
A
b
b
…
…
…
…
…
…
What is the sql command to do like this?
Maybe this will work for you?
create
table #test( cat1varchar(10),cat2
varchar(10),cat3
varchar(10),StartPrice
int,EndPrice
int)insert
into #testvalues
('A','a','a', 12,21)insert
into #testvalues
('A','a','b', 98,11)insert
into #testvalues
('A','a','a', 99,12)insert
into #testvalues
('A','b','b', 12,11)insert
into #testvalues
('A','b','a', 9,0)select
*from #testSelect
Distinct cat1,cat2,cat3from #testdrop
table #test|||You already have the answer... DISTINCT
Try:
|||SELECT DISTINCT Cat1, Cat2, Cat3 FROM mytable
cloris:
You already have the answer... DISTINCT
Try:
SELECT DISTINCT Cat1, Cat2, Cat3 FROM mytable
Haha ha,, i am foolish ........
Thanks cloris
|||It's one of those things. The languages typically have an easy way of doing something if you know where to look. Good Luck.
Subscribe to:
Posts (Atom)