| Author |
Topic |
|
boreddy
Posting Yak Master
172 Posts |
Posted - 2009-01-22 : 05:21:30
|
| In my table i have nearly 400 records in this table contain one column length i need to update the column length with range from 900 to 1000 as a random values thank you in advance |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2009-01-22 : 05:57:39
|
| Ok, I'm sorry if I misunderstood the question but if you want to create a random number between 900 and 1000 you can use MVJ's function dbo.F_RANDOM_INTEGER found here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=69499. To update a table with the values from this function you can do like this:UPDATE table SET myRandomColumn = dbo.F_RANDOM_INTEGER(900, 1000, NEWID())- Lumbago |
 |
|
|
genius_palli
Starting Member
42 Posts |
Posted - 2009-01-22 : 06:14:47
|
| Hi everyone..This is a piece of code in MS-Access, Can anyone please help to write this in SQL.Sum(IIf([Schedule Status]>=2 And Not IsNull([Contractor ID]),1,0))/Count([Event ID])Thanks in advance.Regardsgenius_palli |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-01-22 : 06:23:38
|
quote: Originally posted by genius_palli Hi everyone..This is a piece of code in MS-Access, Can anyone please help to write this in SQL.Sum(IIf([Schedule Status]>=2 And Not IsNull([Contractor ID]),1,0))/Count([Event ID])Thanks in advance.Regardsgenius_palli
May be thiscase when ( [Schedule Status]>=2 and coalesce([Contractor ID]),1))/Count([Event ID])is not null ) then [Schedule Status]+coalesce([Contractor ID]),1))/Count([Event ID]) end |
 |
|
|
genius_palli
Starting Member
42 Posts |
Posted - 2009-01-22 : 06:28:11
|
| thanks raky ..but i think we need to refine it bit more.. why didnt you used sum function..Could you please help..Regardsgenius_palli |
 |
|
|
genius_palli
Starting Member
42 Posts |
Posted - 2009-01-22 : 06:35:25
|
| I have even tried to refine it the following way.. but not getting appropriate results..May i be missing something.. Could you please go through the following piece of codeSum(case when (([Contractor ID] is not null) and ([Schedule Status]>=2)) then 1 else 0 end)/Count([Event ID]) AS [Percent]Thanks in advanceRegardsgenius_palli |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-01-22 : 06:38:31
|
quote: Originally posted by genius_palli thanks raky ..but i think we need to refine it bit more.. why didnt you used sum function..Could you please help..Regardsgenius_palli
In Sql SUM FUNCTION takes only one argument but not multiple...we use Sum function to find sum of values in a column etc |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-01-22 : 06:43:01
|
quote: Originally posted by genius_palli I have even tried to refine it the following way.. but not getting appropriate results..May i be missing something.. Could you please go through the following piece of codeSum(case when (([Contractor ID] is not null) and ([Schedule Status]>=2)) then 1 else 0 end)/Count([Event ID]) AS [Percent]Thanks in advanceRegardsgenius_palli
try thisSum( (case when ([Contractor ID] is not null and [Schedule Status]>=2) then 1 else 0 end)/Count([Event ID])) AS [Percent] |
 |
|
|
genius_palli
Starting Member
42 Posts |
Posted - 2009-01-22 : 06:49:40
|
| There u hit the bulls eye..great.. it worked .. thanks a lot buddy..Keep in touch.Regardsgenius_palli |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2009-01-22 : 06:53:01
|
| Ok, next time post your own topic and stop hijacking others. You completely ruined boreddys post now.- Lumbago |
 |
|
|
genius_palli
Starting Member
42 Posts |
Posted - 2009-01-22 : 06:58:21
|
| Sorry brother.. Ill be careful next time..I need to execute the query as soon as possible and boreddys topic name also was not appropriate..Therefore i posted my query there..I wont repeat the things..Regardsgenius_palli |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-01-22 : 07:05:41
|
quote: Originally posted by genius_palli There u hit the bulls eye..great.. it worked .. thanks a lot buddy..Keep in touch.Regardsgenius_palli
Welcome..... |
 |
|
|
|