[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Scan table for records > 0

I have an Attendance Grid called tblAttendanceGrid.  I have the following columns

Month
Total
DataPresent

How can I write an SQL statement that scans my table and checks to see if anyone has a Total > 0 each month, it will put a "1" in the DataPresent column for that specific record.
0
al4629740
Asked:
al4629740
  • 2
1 Solution
 
Paul MacDonaldDirector, Information SystemsCommented:
Something like...

SELECT Month, Total, CASE WHEN TOTAL > 0 THEN 1 END AS DataPresent FROM MyTable
0
 
al4629740Author Commented:
Yes, however I actually want to put a value of "1" into the actual table
0
 
Paul MacDonaldDirector, Information SystemsCommented:
Something like...

UPDATE MyTable SET DataPresent = 1 WHERE (Total > 0)
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now