Group By?? Group ID?? What do I do?

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Group By?? Group ID?? What do I do?

    I have an Access table designed as follows:

    branch name, name, account number, major type, minor type, status, balance,
    date.

    The 'major types' are the types of accounts. I need to find out who has an
    account type of savings, but no checkings. Further queries are variations of
    this first query.

    For example records might look like
    Denver, Bob, 11111, SAV, EFP, Active, 10.00, 9/27/05
    Denver, Bob, 22222, CK, EFP, Active, 50.00, 09/22/05
    Texas, Fred, 123123, SAV, EFP, Active, 1.00, 02/02/99
    Danville, Dan, 312312, CK, EFP, Active, 12.01, 09.12.99

    The query should see that only Fred has a savings account and not a checking
    account, and this should be the only record displayed. How do I properly group
    to test the conditional?


    RuBot Guest

  2. Similar Questions and Discussions

    1. "group by" - order of rows in group
      this is simple example: TABLE SCHEMA: create table my_table( id int unsigned not null auto_increment primary key, project varchar(255) not...
    2. May 29 Sydney Developers Group study group
      On Monday 29th May, we'll be studying Actionscript 3. Please read the articles prior to the meeting (see <a target=_blank...
    3. cfgrid inside a <cfoutput query="myQuery" group="GROUP">
      Is it possible to use a cfgrid inside a cfoutput with a query and a group. When I try do that I get the following error: INVALID_CHARACTER_ERR:...
    4. group
      I've made a group called everyone. It has its own Sub-directory, "/home/everyone". I have 3 users in the group. Do I have to do anything else so...
    5. Hi to the group
      X-No-Archive: Yes Hi, Been lurking for the most part and I thought posting every now and then, but realized that I had been throwing those out...
  3. #2

    Default Re: Group By?? Group ID?? What do I do?

    So far you don't have to group anything.

    select * from the_table
    where major_type = 'SAV'
    and name not in
    (select name from table
    where major_type = 'CK')

    By the way, the spaces in your tablenames will cause you more trouble than
    they are worth. You should rename them.

    Originally posted by: RuBot
    I have an Access table designed as follows:

    branch name, name, account number, major type, minor type, status, balance,
    date.

    The 'major types' are the types of accounts. I need to find out who has an
    account type of savings, but no checkings. Further queries are variations of
    this first query.

    For example records might look like
    Denver, Bob, 11111, SAV, EFP, Active, 10.00, 9/27/05
    Denver, Bob, 22222, CK, EFP, Active, 50.00, 09/22/05
    Texas, Fred, 123123, SAV, EFP, Active, 1.00, 02/02/99
    Danville, Dan, 312312, CK, EFP, Active, 12.01, 09.12.99

    The query should see that only Fred has a savings account and not a checking
    account, and this should be the only record displayed. How do I properly group
    to test the conditional?




    Dan Bracuk Guest

  4. #3

    Default Re: Group By?? Group ID?? What do I do?

    Actually the field names are a little confusing so I just wrote them out for
    better understanding.

    Here's my query, and here's my error message:
    <cfquery name = "SavNoCk" datasource="TopAccounts">
    select * from acctinfostripped
    where mjaccttypcd = 'SAV'
    and name not in
    (select name from table where mjaccttypcd = 'CK')
    </cfquery>

    "Syntax error. in query expression 'mjaccttypcd = 'SAV' and name not in
    (select name from table where mjaccttypcd = 'CK')"

    RuBot Guest

  5. #4

    Default Re: Group By?? Group ID?? What do I do?

    You didn't use the proper table name in your sub-select. Also, using a NOT
    EXISTS may be more efficient.

    <cfquery name = "SavNoCk" datasource="TopAccounts">
    SELECT *
    FROM acctinfostripped AS a
    WHERE a.mjaccttypcd = 'SAV'
    AND NOT EXISTS
    (SELECT 1
    FROM acctinfostripped AS a1
    WHERE a1.mjaccttypcd = 'CK'
    AND a1.name = a.name)
    </cfquery>

    Phil

    paross1 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139