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
 NEED HELP IN QUERY

Author  Topic 

jhon11
Starting Member

42 Posts

Posted - 2007-11-15 : 12:17:31
Hi ,

I have following results..its like this.



Name Dose PhyId patienid
-------------------------------------------------- Alprazolam .125 0037087 093007210901
Alprazolam .125 0037087 122001073601
Alprazolam .125 0037087 073007498901
Butabarbital .12 0037087 202079304601
Butabarbital .12 0037087 027001185501


Now I want to add one more colum with this column.
One should be give me o/p like AVERAGE PHY DOSE =( .125+.125+.125/3)
where 3= total record for each item.
Results should be like AS FOLLOW.

Name Dose AVG PhyId patienid
-------------------------------------------------- Alprazolam .125 .125 0037087 093007210901
Alprazolam .125 0037087 122001073601
Alprazolam .125 0037087 073007498901
Butabarbital .12 .12 0037087 202079304601
Butabarbital .12 0037087 027001185501


Looking forward to your quick reply.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-15 : 12:23:16
Posting your existing query would help us help you.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jhon11
Starting Member

42 Posts

Posted - 2007-11-15 : 12:39:55
dude..I couldn't find my answer on that link.
Could you please help me out that wht can i do?/..wht fuction i can use and how?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-15 : 12:48:40
I didn't provide an answer. You haven't given us your query yet.

But there is an AVG function in T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-15 : 12:53:53
which one of these "HELP QUERY" posts is causing the issue?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92509
http://www.sqlteam.com/forums/pop_profile.asp?mode=display&id=32821
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92500
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92394
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92517

Every time you ask for help, it comes with a request for sample data, table structures and more information. More often then not, it also seems to exclude gratitude or effort from you.



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -