1

I solved that query... but now I have to merge these two queries:

(SELECT Zila,
COUNT(AbhidayMaster.OfficeRegId) As AbhidayPaidSansthan,
SUM(AbhidayMaster.TotalEmp) As TotalWorkerPaid
FROM PanjikaranMaster, AbhidayMaster
WHERE PanjikaranMaster.OfficeRegId=AbhidayMaster.OfficeRegId
AND AbhidayMaster.DipositDate Between ('2012-06-22') AND ('2012-09-19') GROUP BY Zila)



Select 
((SELECT count(distinct OfficeRegId) FROM PanjikaranMaster)
 -
(SELECT count(distinct OfficeRegId) FROM AbhidayMaster)) As AbhidayNotPaidSansthan
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
azz845
  • 33
  • 7

1 Answers1

2

How about:

SELECT 
   Zila, 
   COUNT(AbhidayMaster.OfficeRegId) As AbhidayPaidSansthan ,
   SUM(AbhidayMaster.TotalEmp) As TotalWorkerPaid
FROM 
   PanjikaranMaster
INNER JOIN
   AbhidayMaster ON PanjikaranMaster.OfficeRegId = AbhidayMaster.OfficeRegId
WHERE
   AbhidayMaster.DipositDate BETWEEN '20120622' AND '20120919'
GROUP BY 
   Zila

I changed your JOIN syntax to use the proper ANSI/ISO standard JOINs - an explicit INNER JOIN with the JOIN condition right there where it belongs (see Bad habits to kick : using old-style JOINs to learn why the "old-style" JOIN is a really bad idea and should be avoided).

I also changed your date string literals to be language- and regional settings-safe - the format is YYYYMMDD (no dashes!)

Community
  • 1
  • 1
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • @user1673240: please **do not** put code samples or sample data into comments - since you cannot format it, it's **extremely hard** to read it.... Instead: **update** your question by editing it to provide that additional information! Thank you. – marc_s Sep 24 '12 at 06:58
  • thanks for your help...... that issue has been solved.. again i am stuck in another query.. please see the above updated query. – azz845 Sep 24 '12 at 07:00