Solved

Scan table for records > 0

Posted on 2013-05-30
3
201 Views
Last Modified: 2013-05-30
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
Comment
Question by:al4629740
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39208438
Something like...

SELECT Month, Total, CASE WHEN TOTAL > 0 THEN 1 END AS DataPresent FROM MyTable
0
 

Author Comment

by:al4629740
ID: 39208492
Yes, however I actually want to put a value of "1" into the actual table
0
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 39208502
Something like...

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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question