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 |
nvoyatzopoulos
Starting Member
7 Posts |
Posted - 2013-02-28 : 07:20:55
|
I'm having those selects and i want to included in one !(select acct.cmpcode,count(LCODE) from ACCT group by acct.cmpcode) as logar,(select count(LCODE) from ACCT where ISTRN = 1 ) as log_kinoum,(select count(ARTID) from arts ) as arthra_eggrafes,(select count(DISTINCT custid) from arts ) as syn_pou_kinith,(select count(DISTINCT trns.LCODE) log_pou_kinithikan from trns ,arts where arts.artid=trns.artid and arts.cmpcode=trns.cmpcode ) as logar_pou_kinithI want each row to start with the acct.cmpcode and then the counts for each one ! How can i DO THIS ??THANKS ! |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-02-28 : 07:37:43
|
The first two can be combined like shown below. As for the rst, how is ACCT table related to arts table, if at all?SELECT cmpcode, COUNT(LCODE) logar, COUNT(CASE WHEN ISNTRN = 1 THEN LCODE END) AS log_kinoumFROM ACCTGROUP BY cmpcode |
|
|
nvoyatzopoulos
Starting Member
7 Posts |
Posted - 2013-02-28 : 07:51:40
|
all connected by cmpcode !quote: Originally posted by James K The first two can be combined like shown below. As for the rst, how is ACCT table related to arts table, if at all?SELECT cmpcode, COUNT(LCODE) logar, COUNT(CASE WHEN ISNTRN = 1 THEN LCODE END) AS log_kinoumFROM ACCTGROUP BY cmpcode
|
|
|
|
|
|
|
|