Jump to content

Recommended Posts

Posted

Na table lo 3state fiels unnayi
Property. Room. Rank
Abc. Tyy. 1
Abc. Tyx. 2
Abc. Hhh. 3
Gri. Tyy. 1
Gri. Aha. 7
Depending on property and room we choose a rank.based on that rank how to find the room with next higher rank for the same property.

Note; ranks are not consecutive

Posted

since you said you are choosing the rank that means you know the rank value...as ranks are always incremented by + just do +1 and search..something like this
SELECT * FROM TABLE WHERE RANK =@Rank +1 -- @Rank has the value that you searched..

Posted

[quote name='ChampakDas' timestamp='1351018362' post='1302677481']
since you said you are choosing the rank that means you know the rank value...as ranks are always incremented by + just do +1 and search..something like this
SELECT * FROM TABLE WHERE[b] RANK =@Rank +1[/b] -- @Rank has the value that you searched..
[/quote]
rank >=@rank+1

Posted

[quote name='ChampakDas' timestamp='1351018362' post='1302677481']
since you said you are choosing the rank that means you know the rank value...as ranks are always incremented by + just do +1 and search..something like this
SELECT * FROM TABLE WHERE RANK =@Rank +1 -- @Rank has the value that you searched..
[/quote]
ranks are not incremental..some properties have ranks like 1,2,10 some have like 5,7,10. Whay to do in this scenario

Posted

nope
[quote name='cherlapalli_jailer' timestamp='1351018462' post='1302677495']
rank >=@rank+1
[/quote]

karma...1min thinking
[quote name='padmasri123' timestamp='1351018564' post='1302677509']
akkada ranks are not consecutive ani ichadu note lo....
[/quote]

Posted
CITI#H@
Posted

SELECT TOP(1) Property, room, Rank FROM TABLE where RANK <> @Rank and Property = @property
group by Property order by rank

edhi chudu mitrama

tondaraga confirm chesthey velli bobbunta

Posted

my 2 cents, Sql Gurinchi anta deep ga teliyadhu baa. but, from the concepts, Case and Correlated Sub Queries use avutayi emo nee case lo. sorry naa ideas tho nee time waste chesthonte...

Posted

select property,room from @table where rank=@rank group by property,room order by property,room

Posted

wrong vayya this will return the room and property that is already selected....top 1 theskovali see my previous post
[quote name='padmasri123' timestamp='1351019055' post='1302677569']
select property,room from @table where rank=@rank group by property,room order by property,room
[/quote]

Posted

[quote name='ChampakDas' timestamp='1351019306' post='1302677603']
wrong vayya this will return the room and property that is already selected....top 1 theskovali see my previous post
[/quote]
emo vayya naaku aa question ardam kaledu....ardaminanthalo adi cheppanu..

Posted

[color=#8A4A0B]SELECT[/color][color=black] l[/color][color=#145680].[/color][color="#000000"]property[/color][color=#145680],[/color][color=black] l[/color][color=#145680].[/color][color="#000000"]rank[/color][color=#145680],[/color][color=black] r[/color][color=#145680].rank[/color][color=black] [/color][color=#8A4A0B]FROM[/color][color=black]
table_name [/color][color=#8A4A0B]AS[/color][color=black] l [/color][color=#8A4A0B]LEFT[/color][color=black] [/color][color=#8A4A0B]JOIN[/color][color=black] table_name [color=#8A4A0B]AS[/color] r [color=#8A4A0B]ON[/color] l[color=#145680].property[/color] [color=#145680]=[/color] r[color=#145680].property[/color]
[/color][color=black] [/color][color=#8A4A0B]WHERE[/color][color=black] l[/color][color=#145680].rank[/color][color=black] [/color][color=#145680]<[/color][color=black] r[/color][color=#145680].rank[/color][color=black] [/color][color=#8A4A0B]ORDER[/color][color=black] [/color][color=#8A4A0B]BY[/color][color=black] l[/color][color=#145680].property[/color][color=black] [/color][color=#8A4A0B]ASC[/color][color=#145680],[/color][color=black] l[/color][color=#145680].rank[/color][color=black] [/color][color=#8A4A0B]ASC[/color][color=#145680];[/color]

×
×
  • Create New...