How to retrieve multiple aggregate columns from SQL Server in a SQL View/Access Query (pref SQL View) -


i have table tblrecords, table inserted 3500 records each day. tblrecords has foreign key linking tblupload. each row identified, apart generic id column, ref (ie: xydg74g) , foreign key column (ie: 345) links tblupload.

the circa 3500 rows uploaded each day same rows uploaded previous day (with updates) additional, new entries last 24 hrs.

each tblrecord row can flagged (bit column) misscustname , misscustnamefixed. view tblrecord rows tblupload, “show me (3500+) records uploaded today”. want, along actual columns in tblrecord see 2 columns, countofprevmisscustname , countofprevmisscustnamefixed

id - ref - custname - countofprevmisscustname- countofprevmisscustnameok  1 - aasd001 - <null> - 14 - 12  2 - zrfg789 - joe bloggs - 10 - 8  3 - yerf777 - mary blyge - 0 - 0 

missing customer name counts total records (historical) transaction missing customer name flagged true. `missnamefixed same.

  1. record 1 has had 14 missing customer name flags , 12 missnamecustnameok flags, still missing customer name.

  2. record 2 has had 10 missing customer name flags, , 8 missnamecustnameok flags , has customer name.

  3. record 3 has never had missing customer name flags , hence no missnamecustnameok flags , has name.

what efficient (quickest , less stress on sql server) implement these 'dcount' style columns. trying dcount column within access painfully slow 9see below), using dao recordsets in access.

select *, dcount("recordid","tblrecordshistorical","ref=" & ref & " , custname null) countofprevmisscustname, dcount("recordid","tblrecordshistorical","ref=" & ref & " , custname not null) countofprevmisscustnameok tblrecords

i ideally able create kind of view, load, use bulk update on table.

i ever work on latest batch of tblrecords once countof... physical columns have been updated once, don't need again.

thnx


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -