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 |
|
emdavies82
Starting Member
2 Posts |
Posted - 2011-10-27 : 04:48:19
|
| Hi,Im trying to teach my self SQL query. So sorry if this sounds stupid.I want to find out how many people are living at the same address so have done this.SELECT COUNT(Address_Line_1) AS Expr1, Address_Line_1FROM Pers_Static_Personnel_HistoryGROUP BY Address_Line_1HAVING (COUNT(Address_Line_1) > 1)ORDER BY COUNT(Address_Line_1)However its returning resutls such as 5 live at flat 1. This could not be the same address so I need to add in the post code.How do I change this so It will look at the Adress line 1 field and the postcode field then count how many of theose two records together there are?Thanks for your help |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-27 : 04:49:56
|
| [code]SELECT COUNT(1) AS Expr1, Address_Line_1,PostCodeFROM Pers_Static_Personnel_HistoryGROUP BY Address_Line_1,PostCodeHAVING (COUNT(1) > 1)ORDER BY COUNT(1)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|