How can I pull of this query?

This works:

select DISTINCT DP.int_DEVELOPERS_Tool_Id as project_rank from net_BudgetTools..tbl_DEVELOPERS_Projects DP

Thing is, I want to list them by their project_rank_id.

I've done this before, but I've forgotten how. How can I list these distinct values according to their project_rank_id? What would that select statement look like?

Thanks!
Bruce GustPHP DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bruce GustPHP DeveloperAuthor Commented:
OK, I've been working and I've got this to work...

$sql="select DP.int_DEVELOPERS_Tool_Id, DPS.int_DEVELOPERS_ProjectStatus_Id as status_id from net_BudgetTools..tbl_DEVELOPERS_Projects DP
LEFT JOIN
net_BudgetTools..tbl_DEVELOPERS_ProjectStatuses      DPS      
ON DP.int_DEVELOPERS_ProjectStatus_Id = DPS.int_DEVELOPERS_ProjectStatus_Id AND DPS.bit_Is_Active = 1";

...but when I do this:

$sql="select DP.int_DEVELOPERS_Tool_Id, DPS.int_DEVELOPERS_ProjectStatus_Id as status_id from net_BudgetTools..tbl_DEVELOPERS_Projects DP
LEFT JOIN
net_BudgetTools..tbl_DEVELOPERS_ProjectStatuses      DPS      
ON DP.int_DEVELOPERS_ProjectStatus_Id = DPS.int_DEVELOPERS_ProjectStatus_Id AND DPS.bit_Is_Active = 1
GROUP BY
DP.int_DEVELOPERS_Tool_Id";

I get an error that reads as follows:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 8120 General SQL Server error: Check messages from the SQL Server [8120] (severity 16) [select DP.int_DEVELOPERS_Tool_Id, DPS.int_DEVELOPERS_ProjectStatus_Id as status_id from net_BudgetTools..tbl_DEVELOPERS_Projects DP LEFT JOIN net_BudgetTools..tbl_DEVELOPERS_ProjectStatuses DPS ON DP.int_DEVELOPERS_ProjectStatus_Id = DPS.int_DEVELOPERS_ProjectStatus_Id AND DPS.bit_Is_Active = 1 GROUP BY DP.int_DEVELOPERS_Tool_Id]' in /var/www/html/testsite/c0gusb1/mssql_class.php:19 Stack trace: #0 /var/www/html/testsite/c0gusb1/mssql_class.php(19): PDO->query('select DP.int_D...') #1 {main} thrown in /var/www/html/testsite/c0gusb1/mssql_class.php on line 19  

The select statement works fine and it would seem to be that "GROUP" is what I need, yet I can't implement without getting an error. What am I doing wrong?
0
Bruce GustPHP DeveloperAuthor Commented:
Also, I'm querying a MSSQL database, if that makes any difference.
0
InsoftserviceCommented:
Please provide the table schema with few data so that it would be easy for us to provide you with correct sql statements
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bruce GustPHP DeveloperAuthor Commented:
I don't have it, but your suggestion confirms the fact that I need to reach out to my .NET counterpart and get that schema because the error messages by themselves don't really help.

I'll get back with you.
0
Bruce GustPHP DeveloperAuthor Commented:
insoftservice - I'm going to award you the points, simply because you took the time to respond.

I did get with my .NET counterpart and was able to access MSSMS which gave me a the chance to see the database and proof my code.

The problem was remedied by establishing a new connection. I was running a separate select statement within a loop. Turned out to be problematic, in that I was attempting to another query within the same connection. Never encountered that before, but once I opened up a new connection, the whole thing came together!

Thanks for your input!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.