Need help with Oracle 2 table join with the count function.

From: Gary Clift <gclift_at_avaya.com>
Date: 16 Jul 2001 10:20:35 -0700
Message-ID: <287b284e.0107160920.1e88a441_at_posting.google.com>


Need help with Oracle 2 table join with the count function. Oracle8i Enterprise Edition Release 8.1.7.0.0

I need help selecting a user record and the amount of records in a transaction table associated with that user. The idea is to delete only users that have 0 transactions. I do not want to create any orphans in the transaction table. Here is the SQL statement I&#8217;m trying, of course it doesn&#8217;t work&#8230;.

SELECT a.bu_userid, a.bu_seclev, a.swlogin, count(b.bt_transid) FROM bot_user a, bot_transaction b
WHERE a.bu_seclev < 0 AND b.bt_userid = a.bu_userid GROUP BY a.bu_userid

Here is how the tables are built:
BOT_USER
-- bu_userid (PK)

BOT_TRANSACTION
-- bt_transid (PK)

  • bt_userid (FK to bot_user) &#8230; &#8230; &#8230;

Any help would be appreciated!
Gary

Love live News Groups&#8230; Received on Mon Jul 16 2001 - 19:20:35 CEST

Original text of this message