Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select queries

Author  Topic 

Indrajit
Starting Member

11 Posts

Posted - 2012-07-31 : 06:42:34
In my table
Rack Cell Qty
A1 X 20
A1 Y 30
A1 Z 10
B1 A 34
B2 B 50
how to select only A1 Rack with related cell Value without giving condition

IndrajitDasgupta

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-31 : 06:51:11
not sure what you mean about the condition

select *
from tbl
where rack = 'A1'

if you don't want a where clause
select top 3 *
from tbl
order by Rack


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2012-07-31 : 06:53:23
Of course you can't - what kind of constraint is "not giving condition".

select t.* from table t inner join (select 'a1' rack) x on t.rack=x.rack.

Even if you join to a table it's still a condition - what are you trying to do?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-31 : 09:46:29
[code]
select top 1 with ties *
from table
order by Rack
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2012-07-31 : 10:14:33
The condition is that A1 is the first alphabetically (or top 3) in the table. It's still a condition! The only unconditional set of a set is the set :)
Maybe the OP can explain the reason and clarify the question. Seems a bit pointless so far.
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-31 : 11:16:13
It's a condition of the data not a conditional clause in the query.
Yep - the suggestions are as pointless as the question.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -