Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine 2 queries

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
US
I have a query that looks like this

SELECT ContID, CostCenID, ContName, ContExp, WarExp, ContCost, Descrip

FROM Contracts"

WHERE (ContractExpiration >= '&quot; & BDATE & &quot;' And ContractExpiration <= '&quot; & EDATE & &quot;')

GROUP BY ContractExpiration
ContractExpiration&quot;

The way this works is that is pulls all the date for a certain month and displays the names of the contracts in a calendar with the corresponding day and display all information in that month at the bottom of the page. Works great.

But a change has been requested to display the number of records per day instead of the name. Now I can create a query to count them and I have the above query. but what I cannot do is merge the queries together to one so I would only have to go to the database once or do I have no choice and make 2 queries. I am tring to get a result kind of like this.

Total CostCenID, ConName, ContExp
2 1111 Dell 1/1/03
1 1132 HP 1/3/03
10 1352 xyz 2/10/03
1 3215 abc 3/2/03 AJ
I would lose my head if it wasn't attached. [roll1]
 
The query you showed looks incomplete. If I understands you correctly, you could use a query like

select count(*) as Total, CostCenID,ConName, ContExp
from contracts
WHERE (ContractExpiration >= '&quot; & BDATE & &quot;' And ContractExpiration <= '&quot; & EDATE & &quot;')
GROUP BY CostCenID,ConName, ContExp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top