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 |
djb27
Starting Member
1 Post |
Posted - 2013-02-26 : 22:02:22
|
Hi Everyone, I have 3 tables: BASKET, STORE_MSA, and SKUINFO having between hundreds and thousands of rows of data. I am trying to identify the number of customers (in the table defined as BASKETNO) served across stores over the year. I only need to identify the customers from Illinois.BASKET has the following columns: BASKETNO, STORE, DEPT, DEPTDESC, STYLE, SKU, QTY, AMT, RETAIL, ORGPRICE, COST, BRAND, SALEDATESTORE_MSA has the following columns: STORE, CITY, STATE, ZIP, MSA, MSA_NAME, MSA_POP, MSA_REGION Some assistance would be greatly appreciated!David Burr |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-02-26 : 22:11:11
|
probably something like thisSELECT COUNT (*)FROM BASKET bINNER JOIN STORE_MSA s ON b.STORE = s.STOREWHERE b.SALEDATE BETWEEN '2012-01-01' AND '2012-12-31' AND CITY = 'xxx'if it is not what you wanted, please do post some sample data and the expected result KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-26 : 23:08:15
|
if SALEDATE is of type datetime use this to cover complete date rangeSELECT COUNT (*)FROM BASKET bINNER JOIN STORE_MSA s ON b.STORE = s.STOREWHERE b.SALEDATE >='2012-01-01' AND b.SALEDATE<'2013-01-01'AND STATE = 'IL' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|