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.
| Author |
Topic |
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-01-18 : 10:59:33
|
| hi,I have 2 fields sum and count.sum = 720count = 400so far I have the ration 720:400Do you know how I can use SQL to show the smallest ratio ? |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-01-18 : 11:09:10
|
| Not clear what you want. Post the table structures, sample data and expected output.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-01-18 : 11:22:53
|
| 60:20 is a 3:1 ratio.I have table1 with field1 and field2 , so far I do convert(varchar,field1) + ':'+ convert(carchar,field1)This is displayed as 60:20but I need to work out the smallest ratio.. |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2008-01-18 : 11:39:24
|
| [code]declare @Value1 intdeclare @Value2 intset @Value1 = 720set @Value2 = 400select top 1000 IDENTITY(int, 1,1) as Valueinto #SequentialValuesfrom master..spt_values A, master..spt_values Bselect @Value1/max(Value) as Value1, @Value2/max(Value) as Value2from #SequentialValueswhere @Value1 % Value = 0 and @Value2 % Value = 0drop table #SequentialValues[/code]e4 d5 xd5 Nf6 |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-01-18 : 11:41:04
|
| thank you so much ! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|