December 11, 2008 at 6:50 am
Create Table Temp(
nameX VARCHAR(10),
moneyX int
);
INSERT INTO temp VALUES('a',10);
INSERT INTO temp VALUES('a',5);
INSERT INTO temp VALUES('a',15);
INSERT INTO temp VALUES('b',5);
INSERT INTO temp VALUES('b',20);
My question is:
How can I calculate the average maximum earner? a or b?
Thanks in Advace
Sarfaraj
December 11, 2008 at 7:05 am
Sarfaraj Ahmed (12/11/2008)
Create Table Temp(nameX VARCHAR(10),
moneyX int
);
INSERT INTO temp VALUES('a',10);
INSERT INTO temp VALUES('a',5);
INSERT INTO temp VALUES('a',15);
INSERT INTO temp VALUES('b',5);
INSERT INTO temp VALUES('b',20);
My question is:
How can I calculate the average maximum earner? a or b?
Thanks in Advace
Sarfaraj
If you can define it, there's someone here who can code it.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
December 11, 2008 at 7:22 am
to find the name that has the highest average moneyx use;
SELECT TOP 1 namex,AVG(moneyx) AS MoneyXAvg
FROM [Temp]
GROUP BY namex
ORDER BY MoneyXAvg DESC
December 11, 2008 at 8:17 pm
Thank you very much
It does work
December 11, 2008 at 8:18 pm
steveb (12/11/2008)
to find the name that has the highest average moneyx use;
SELECT TOP 1 namex,AVG(moneyx) AS MoneyXAvg
FROM [Temp]
GROUP BY namex
ORDER BY MoneyXAvg DESC
Thank You Very Much
It does work.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply