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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping Problems....

Status
Not open for further replies.

vbjohn

Programmer
Joined
Aug 23, 2001
Messages
67
Location
US
I have this big query that I am using in the Visual Basic program. I need to group togther "CHEKNMBR".


The problem is that the "CHEKNMBR" needs to be grouped by... Regular Checks and Direct Depoist Checks.

Regular Checks always start with "79------"
and
Direct Deposites always start with "DD-------"

Is there any way that I can do this?

...Please Help...
 
If sorting is the problem then this will do it -

Code:
SELECT cheknumbr
ORDER BY SUBSTRING(cheknumbr, 1, 2)

If labels are needed add this -
Code:
SELECT
   CASE SUBSTRING(cheknumbr, 1, 2)
      WHEN '79' THEN 'Regular Check'
      WHEN 'DD' THEN 'Direct Deposit'
      ELSE 'Other'
   END AS "Type of Deposit",
   cheknumbr

If subtotals are needed then -

Code:
SELECT SUBSTRING(cheknumbr, 1, 2), SUM(amount_of_deposit)
GROUP BY SUBSTRING(cheknumbr, 1, 2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top