June 3, 2011 at 12:36 pm
Hello, i was searching for some help, and maybe someone could help me with my problem!
I have to get a MAX from an Account Balance..
I'm using a query to get all balances, and its working Perfect, but the problem comes when trying to get the MAX...
that's he query I use :
SELECT Balance, Customer.FName, Customer.Address
FROM Accounts INNER JOIN
Account_mm_Customer ON Accounts.AccountID = Account_mm_Customer.AccountID INNER JOIN
Customer ON Account_mm_Customer.CustomerID = Customer.CustomerID
GROUP BY Customer.FName, Customer.Address, Balance
I'm using SQL Server 2005
if anyone can help plz let me know
I appreciate it
June 3, 2011 at 12:51 pm
Something like
SELECT MAX(Balance) AS BalanceMax, Customer.FName, Customer.Address
FROM Accounts INNER JOIN
Account_mm_Customer ON Accounts.AccountID = Account_mm_Customer.AccountID INNER JOIN
Customer ON Account_mm_Customer.CustomerID = Customer.CustomerID
GROUP BY Customer.FName, Customer.Address --, Balance
June 3, 2011 at 12:57 pm
LutzM (6/3/2011)
Something like
SELECT MAX(Balance) AS BalanceMax, Customer.FName, Customer.Address
FROM Accounts INNER JOIN
Account_mm_Customer ON Accounts.AccountID = Account_mm_Customer.AccountID INNER JOIN
Customer ON Account_mm_Customer.CustomerID = Customer.CustomerID
GROUP BY Customer.FName, Customer.Address --, Balance
Yep I tried that but still giving me almost same result, not working :/
June 3, 2011 at 1:16 pm
The syntax is correct. It returns data. So it IS working.
The fact you're expecting other results implies you're looking for a different query then. 😉
Since we don't know your data nor can we look over your shoulder, it's hard to help you any further without some more detailed information.
Maybe you could have a look at the first link in my signature and post table def and sampel data in a ready to use format together with what you're looking for.
June 3, 2011 at 3:52 pm
LutzM (6/3/2011)
The syntax is correct. It returns data. So it IS working.The fact you're expecting other results implies you're looking for a different query then. 😉
Since we don't know your data nor can we look over your shoulder, it's hard to help you any further without some more detailed information.
Maybe you could have a look at the first link in my signature and post table def and sampel data in a ready to use format together with what you're looking for.
I know that the Syntax is correct. and that it returns data, but you can't say that it IS working, because its not, it should give only one record which is the max of "Balance" but its giving me the whole records, all balances. So its Not Working :/
Anyone can also offer an opinion? thank you!
June 3, 2011 at 5:12 pm
Please re-read my previous post regarding some test data and help us help you.
It should return MAX(Balance) per Customer.FName and Customer.Address. So I would expect one row per customer. If there are multiple combination of FName and Address then yes, there will be more than one row.
If that's not what you're looking for, please provide more detailed information (table def, sample data, expected result, like I asked for in my previous post).
June 3, 2011 at 5:17 pm
me.hacked (6/3/2011)
Hello, i was searching for some help, and maybe someone could help me with my problem!I have to get a MAX from an Account Balance..
I'm using a query to get all balances, and its working Perfect, but the problem comes when trying to get the MAX...
that's he query I use :
SELECT Balance, Customer.FName, Customer.Address
FROM Accounts INNER JOIN
Account_mm_Customer ON Accounts.AccountID = Account_mm_Customer.AccountID INNER JOIN
Customer ON Account_mm_Customer.CustomerID = Customer.CustomerID
GROUP BY Customer.FName, Customer.Address, Balance
I'm using SQL Server 2005
if anyone can help plz let me know
I appreciate it
SELECT TOP 1 Balance, Customer.FName, Customer.Address
FROM Accounts INNER JOIN
Account_mm_Customer ON Accounts.AccountID = Account_mm_Customer.AccountID INNER JOIN
Customer ON Account_mm_Customer.CustomerID = Customer.CustomerID
GROUP BY Customer.FName, Customer.Address, Balance
ORDER BY Balance DESC
???? is that what you mean?
MM
select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);
June 4, 2011 at 9:26 am
Thank mate, ur the man 🙂 Solved 🙂
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply