Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Noob with query question

Author  Topic 

ISBB
Starting Member

12 Posts

Posted - 2010-11-02 : 15:54:02
Sooooooo in my peabrain rationale that seemed like this was going to work but it didn’t

select MIN(s.importdate) as Importdate, i.STATE,COUNT(*) as Records

from Nationwide.dbo.NAT91410 as i

left join CCISUP.dbo.suppression s on s.tl1 = i.phone
left join CCISUP.dbo.purge p on p.tl1 = i.phone
left join CCISUP.dbo.NS ns on ns.tl1 = i.PHONE

where s.tl1 is NULL
and ns.tl1 is null
and p.tl1 is NULL
and i.PHONE is not null

group by i.STATE order by i.STATE


I get this for results.

Importdate STATE Records
NULL AL 1
NULL AR 37303
NULL GA 78124
NULL KY 154343
NULL MD 676850
NULL MS 87146
NULL NC 814292
NULL TN 1
NULL VA 862185


I did however get this to work properly but now its just putting the 2 together lol

select MIN(s.importdate) as Importdate, s.state
from ccisup.dbo.suppression as s
group by s.STATE order by s.STATE


Any help or advice would be greatly appreciated.

Yep.. Point and Click dont work here..

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-02 : 15:56:08
You haven't explained what your query is supposed to be doing, nor have you provided sample data and expected result set. Please re-read your post and take a step back to see.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ISBB
Starting Member

12 Posts

Posted - 2010-11-02 : 16:04:41
in a nutshell.. i want to end up with the Min(importadate) from ccisup.dbo.suppression to be added in the collumn that shows null.

The original query in itself compares the 3 tables and only pulls records from nationwide.dbo.91410 that are NOT in the other 3 tables and gives a count of the available numbers.

The ccisup.dbo.suppression table includes importdates which is a autofill when i import data into that table. I need to know the MIN(importdate) is along with the state and how many records are left.

Yep.. Point and Click dont work here..
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-11-04 : 06:42:06
Is there any relation between CCISUP.dbo.suppression and Nationwide.dbo.NAT91410 ?

PBUH

Go to Top of Page

ISBB
Starting Member

12 Posts

Posted - 2010-11-04 : 15:52:03
nope.. but the more i think about it the less sense it makes so i probably wont likely be able to acomplish it.. ohh well.. was a thought. Ill just have to do them in 2 seperate queries...

The only way they are related is i dont want any records from nationwide db that are also in that suppression db..

Yep.. Point and Click dont work here..
Go to Top of Page
   

- Advertisement -