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 |
|
pavlos
Yak Posting Veteran
59 Posts |
Posted - 2011-12-18 : 20:19:14
|
| hey guysthis is the table i have (id is a primary key):ID |TRANSNUMBER |STORE |DATE1 |100 |10 |2011-01-012 |100 |11 |2011-01-013 |100 |11 |2011-01-014 |102 |12 |2011-01-015 |102 |13 |2011-01-016 |103 |14 |2011-01-017 |104 |10 |2011-01-01So we can have the same transaction number for different stores. Every item that gets sold will have an Id even if its on the same transactionnumber.I need to work out the total number of items sold at one storeand the total number of transactions using the one query.the table is called inventoryi have worked out to determine the amount of items sold i need to count the total number of id's by the storeandto calculate the total number of customer i need to count the total number of transactions per store.however when i count the id and transaction number using simple count measures such as COUNT(id) and COUNT(transnumber) it will return the same result.. which is wrongSELECT COUNT(TRANSNUMBER), COUNT(ID), STORE, DATEFROM INVENTORYGROUP BY STORE,DATEthis returns the same result for both counted numbers...do i need to write multiple sql queries into the one.. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-12-18 : 20:26:57
|
[code]SELECTCOUNT(DISTINCT TRANSNUMBER),COUNT(ID),STORE,DATEFROM INVENTORYGROUP BY STORE,DATE[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
pavlos
Yak Posting Veteran
59 Posts |
Posted - 2011-12-18 : 20:30:26
|
| wow.. that was easy enough.. thanks again khtan! |
 |
|
|
|
|
|