+ Reply to Thread
Results 1 to 11 of 11

Update query with count

  1. #1
    Registered User
    Join Date
    12-26-2012
    Location
    Meerut
    MS-Off Ver
    Excel 2007
    Posts
    86

    Update query with count

    Dear Experts

    now i make a select query
    as

    select header,count(header)
    from database
    group by header

    which create a new database with my requirement then i have to do query as lookup to update my existing databse :-(

    here i want an UPDATE query which can update my existing database instead of new :-)

    Pl. help


    R's
    Amit Kumar

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,941

    Re: Update query with count

    Seems that you may have solved this with your later update query thread. If so, please mark as solved.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    12-26-2012
    Location
    Meerut
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Update query with count

    Sorry but is didnt get i have the same issue

    i want my database to be updated with UPDATE query

    pl. tell me the query

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,941

    Re: Update query with count

    I ran your query and it updated. It works. I don't know what else to provide you. It currently gives you the same number in Field B as in Field A. What do you want in Field B if not what you have in your query.

  5. #5
    Registered User
    Join Date
    12-26-2012
    Location
    Meerut
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Update query with count

    Here i attached a ms-access template 2007.

    Which Contain two field as given below

    Cellno, Cellno count
    9627771750 1
    9627771751 1
    9627771752 5
    9627771752 5
    9627771752 5
    9627771752 5
    9627771752 5
    9627771757 1

    Note:- i need this in one update query in updateable table..

    now a days i use this query

    select Cellno,count(Cellno)as [Cellno count]
    from Dbase
    group be Cellno

    result is a non-updateable table get create the i have to map this into my main file

    hope u understand what i need??
    Attached Files Attached Files

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,941

    Re: Update query with count

    See attached. First need to build Aggregate Query to obtain counts. Next need to build a MakeTable query if you want in a new table. If it is adequate to have the results in a query, then the make table query should be changed to a select query. You cannot make an update query with an aggregate query joined. Access won't let this happen. These are workarounds.
    Attached Files Attached Files
    Last edited by alansidman; 01-12-2013 at 11:01 PM.

  7. #7
    Registered User
    Join Date
    12-26-2012
    Location
    Meerut
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Update query with count

    Thanx alansidman

    But facing one more Problem.

    in this query i have to check manual dbase and delete the record 1 among 2 or 2 among 3

    Is there any query which can get the result as Excel like True False.(may be some thing else)

    E.g if a Cellno. having 3 time in a table then qwery shown 2 time True and 1 time False (may be some thing else)
    so that i could delete easily the cellno which is multiple time,

    hope u understand what i need..

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,941

    Re: Update query with count

    Consider using the Distinct function in your SQL statment.

    Look at this explanation: http://www.w3schools.com/sql/sql_distinct.asp

  9. #9
    Registered User
    Join Date
    12-26-2012
    Location
    Meerut
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Update query with count

    Thanx for giving me solution

    But if i do this with a single column as (select distinct Cellno from Dbase) then it works properly, but if i do this with multiple data then it doesn't work.

    I m using this query

    (select distinct Cellno,* from Dbase)

    Pl. look where m creating mistake

    I also attached as Sample data sheet. pl. look into this..

    R's
    Amit Kumar
    Attached Files Attached Files

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,941

    Re: Update query with count

    Try distinct row. Go back to the link for SQL and look at distinct row.

  11. #11
    Registered User
    Join Date
    01-04-2013
    Location
    Delhi, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Update query with count

    If this is what you are looking for..

    SELECT Tb2.Number, Count(Tb2.Number) AS CountOfNumber, IIf(Count([Tb2]![Number])<>1,"Multi","Single") AS Status INTO NewTable
    FROM Tb2
    GROUP BY Tb2.Number;

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1