Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2011, 01:39 PM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with SQL statement that compairs dates.

Good Morning!

It may be simple or it may be impossible. Situation:
A person gets flagged. they have a flag start date(DATE_REPT_SFPA1) and a flag end date (DATE_REMVD_SFPA1). There is 1 throgh 5. so max of 5 times someone can get flagged.

The data in the columns is MM/DD/YYYY 0.00


Goal:

To find the total # of people currently flagged.
So...
If person has DATE_REPT_SFPA1 and no DATE_REMVD_SFPA1 = flagged.
If person has DATE_REPT_SFPA1 and a DATE_REMVD_SFPA1 = not flagged.

I currently have.
SELECT COUNT (DATE_REPT_SFPA1) from bla.dbo.bla WHERE DATE_REPT_SFPA1 <> ' ' (because yes... its blank not NULL)

SELECT COUNT (DATE_REMVD_SFPA1 ) from bla.dbo.bla WHERE DATE_REMVD_SFPA1 <> ' '

it gives me 2 results 549 with start flag dates and 479 with end flag dates. So 70 people are currently flagged.

Now... How do combine and subtract those numbers?

The over all goal is to pull real time data (in visual studio) in a graph to show # of people each office has and how many of that office's people are currently flagged.

Sorry I'm new and have been doing alot of self teaching, and going to a course in 4 months.

Thank you!





Similar Threads
Thread Thread Starter Forum Replies Last Post
help with SQL dates Byock SQL Server 2000 1 March 23rd, 2006 12:58 PM
If Then Statement With Dates hcweb Classic ASP Basics 8 January 4th, 2006 09:21 PM
Getting Dates in SQL meichmann SQL Server 2000 5 April 18th, 2005 10:58 AM
SQL dates - Problem malecumbria Classic ASP Databases 4 February 16th, 2005 01:18 PM
International Dates in SQL owain SQL Language 2 June 13th, 2003 03:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.