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.
Author |
Topic |
rsullivan
Starting Member
2 Posts |
Posted - 2014-11-11 : 14:02:41
|
I have 3 fields Company, vendor, invoice and I am having trouble with this query. I need to determine when Vendor and Invoice are the same and occur greater than once while company is different. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-11-11 : 14:37:51
|
select vendor, invoice, count(*)from yourtablegroup by vendor, invoicehaving count(*) > 1Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
rsullivan
Starting Member
2 Posts |
Posted - 2014-11-11 : 14:56:37
|
Sorry I really didn't word that correctly.. What I was trying to do is Vendor and invoice are the same but the company is not the same.cmp vend invcmp1 vndr1 inv1cmp1 vndr1 inv1cmp2 vndr1 inv1 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-11-11 : 14:58:55
|
select vend, inv, cmp, count(*)from yourtablegroup by vend, inv, cmphaving count(*) > 1Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|