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!

Report to include two count fields!

Status
Not open for further replies.

sammybee77

Technical User
Jun 18, 2001
98
GB
Hi,

I'm writing a report in SQL, which I would like to do a count of a field where another field = condition a and then count again off the same table where same field = condition b. The table I am reporting off is outer joined to my main table. Any ideas?
 
why not use a lexical param on a condition, or use another query, so your report has the same query asain.

and in your layout edditor use a program unit to display true based on condition.

 
you can easily do this with a decode inside a sum function
sum(decode(fielda, 'value1', 1,0)) as COUNT_OF_A
says everytime fielda = 'value1' add 1 to the sum otherwise add a 0 and name this sum COUNT_OF_A.
your other count is
sum(decode(fielda, 'value2', 1, 0)) as COUNT_OF_2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top