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.
| Author |
Topic |
|
Ichiro Sato
Starting Member
5 Posts |
Posted - 2008-06-01 : 23:30:40
|
| im supposed to output the companies that have commission rates highter than company "Industrial Appparatus".is there some whay to modify this code so that it will work?commissionrate > ALL(Select commissionRate From salescompanydomestic Where companyName = 'Industrial Appparatus') |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-06-02 : 00:29:55
|
quote: Originally posted by Ichiro Sato im supposed to output the companies that have commission rates highter than company "Industrial Appparatus".is there some whay to modify this code so that it will work?commissionrate > ALL(Select commissionRate From salescompanydomestic Where companyName = 'Industrial Appparatus')
SELECT CompanyName,commissionrateFROM salescompanydomesticWHERE commissionrate > ( SELECT commissionRate FROM salescompanydomestic WHERE companyName = 'Industrial Appparatus') |
 |
|
|
Ichiro Sato
Starting Member
5 Posts |
Posted - 2008-06-02 : 00:32:53
|
| When i try that i get this errorMsg 512, Level 16, State 1, Line 1Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-02 : 00:33:46
|
For giving a soln on this, we need more info on your table structure with some sample data. Could you post them please?As of now i can only tell it would be something likeSELECT * FROM YourTableWHERE commissionrate > (SELECT MAX(commissionrate) From salescompanydomestic Where companyName = 'Industrial Appparatus') |
 |
|
|
Ichiro Sato
Starting Member
5 Posts |
Posted - 2008-06-02 : 00:37:57
|
| I have two tables that I am using for this querySalesCompanycompanyId companyName salesNetworkIndicator----------- ------------------------------ ---------------------111 Industrial Appparatus D222 AIE Inc D333 Chalman Technologies D444 Langley Macinery D555 Electronic Assembly Products D666 KDF Company D777 AKA Northern Asia I888 Algon EAPRO I999 Algon France I1000 3D Automation India I1100 Enlaces Industriales I1200 Townsend Coates Ltd I(12 row(s) affected)SalesCompanyDomesticcompanyId state phone commissionRate----------- -------------------- -------------------- ---------------------------------------111 Alabama 770-9191913 0.0300222 Alaska 425-4554697 0.0500333 California 714-5651234 0.0100444 Florida 352-1234343 0.0200555 Utah 303-1235465 0.0400666 Ohio 440-9897867 0.1000(6 row(s) affected) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-02 : 00:43:50
|
quote: Originally posted by Ichiro Sato I have two tables that I am using for this querySalesCompanycompanyId companyName salesNetworkIndicator----------- ------------------------------ ---------------------111 Industrial Appparatus D222 AIE Inc D333 Chalman Technologies D444 Langley Macinery D555 Electronic Assembly Products D666 KDF Company D777 AKA Northern Asia I888 Algon EAPRO I999 Algon France I1000 3D Automation India I1100 Enlaces Industriales I1200 Townsend Coates Ltd I(12 row(s) affected)SalesCompanyDomesticcompanyId state phone commissionRate----------- -------------------- -------------------- ---------------------------------------111 Alabama 770-9191913 0.0300222 Alaska 425-4554697 0.0500333 California 714-5651234 0.0100444 Florida 352-1234343 0.0200555 Utah 303-1235465 0.0400666 Ohio 440-9897867 0.1000(6 row(s) affected)
SELECT *FROM SalesCompanyDomestic scdINNER JOIN SalesCompany scON sc.companyId=scd.companyIdWHERE scd.commissionRate >(SELECT scd.commissionRateFROM SalesCompanyDomestic scdINNER JOIN SalesCompany scON sc.companyId=scd.companyIdAND sc.CompanyName='Industrial Appparatus') |
 |
|
|
Ichiro Sato
Starting Member
5 Posts |
Posted - 2008-06-02 : 00:47:04
|
| Thanks! |
 |
|
|
|
|
|