SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Please Help Subquiries
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nvoyatzopoulos
Starting Member

Greece
7 Posts

Posted - 02/28/2013 :  07:20:55  Show Profile  Reply with Quote
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_kinith

I want each row to start with the acct.cmpcode and then the counts for each one ! How can i DO THIS ??

THANKS !

James K
Flowing Fount of Yak Knowledge

3589 Posts

Posted - 02/28/2013 :  07:37:43  Show Profile  Reply with Quote
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_kinoum
FROM
	ACCT
GROUP BY 
	cmpcode
Go to Top of Page

nvoyatzopoulos
Starting Member

Greece
7 Posts

Posted - 02/28/2013 :  07:51:40  Show Profile  Reply with Quote
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_kinoum
FROM
	ACCT
GROUP BY 
	cmpcode


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000