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
 Urgent Query Problem!!!!!

Author  Topic 

prashantdighe
Starting Member

21 Posts

Posted - 2012-05-14 : 01:54:49
Hi all,

I have stuck with some freaking problem....

Following table which i have to deal....

[Session_Type_ID] [Cntribution][Learning] [Intellectual]
1 9 10 0
2 5 7 8
3 4 2 9
4 5 9 5
[Effectiveness] [Program_Name] [Session_Title] [Session_Taken_By]
5 KBC ASP.NET PRASHANT
7 KBC SQL TARUN
6 KBC VB.NET MAYUR
8 XYZ HTML RAJIV
I have to select Contribution, Learning, Intellectual, Effectiveness in such a way so that the rating of below 3 and above 10 will not be counted as well as the average of them counted in group of Session_Taken_By and Session_Title and for same program name

Please help!!!!!!!!

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-14 : 07:49:15
quote:
Originally posted by prashantdighe

Hi all,

I have stuck with some freaking problem....

Following table which i have to deal....

[Session_Type_ID] [Cntribution][Learning] [Intellectual]
1 9 10 0
2 5 7 8
3 4 2 9
4 5 9 5
[Effectiveness] [Program_Name] [Session_Title] [Session_Taken_By]
5 KBC ASP.NET PRASHANT
7 KBC SQL TARUN
6 KBC VB.NET MAYUR
8 XYZ HTML RAJIV
I have to select Contribution, Learning, Intellectual, Effectiveness in such a way so that the rating of below 3 and above 10 will not be counted as well as the average of them counted in group of Session_Taken_By and Session_Title and for same program name

Please help!!!!!!!!

I must admit that I am not following your requirement. If you can post the DDL for the tables, representative sample input data and the corresponding expected output, people on the forum should be able to offer suggestions.

Take a look at Brett's blog about how to get the DDL's etc.: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Perhaps this?
SELECT
*,
AVG(effectiveness*1) OVER (PARTITION BY [Program_Name]) AS Average
FROM
YourTable
WHERE
Effectiveness >= 3 AND Effectiveness <= 10;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-14 : 23:12:51
are posted data from same table of multiple tables? if from multiple, i cant see any fields by which they're linked.

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

Go to Top of Page
   

- Advertisement -