Solved

Scan table for records > 0

Posted on 2013-05-30
3
199 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

Suggested Solutions

Title # Comments Views Activity
Log Backup 2 21
Troubleshooting Methodology - steps 3 36
Syntax using Declare 4 38
tempdb latch contention 12 47
Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now