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 |
|
Kim
Starting Member
3 Posts |
Posted - 2004-09-21 : 07:54:07
|
| Hi,The following query:Select h.HeaderID, h.FromDat, h.TomDat, ta.CountryFrom SvHeader hJoin SvTillAdress ta on h.HeaderID = ta.HeaderIDWhere h.AdressandTyp = 'TFS'And ta.Country<> ''And ta.Country<> 'Sverige'And ta.AdressKalla = 'P'And h.FromDat >= '2003-01-01'gives the following resultset with some 5000 rows:HeaderID FromDat TomDat Country2514241 2003-01-07 00:00:00.000 2003-03-20 00:00:00.000 SPANIEN2514450 2003-01-04 00:00:00.000 2003-04-15 00:00:00.000 FRANKRIKE2811566 2003-07-09 00:00:00.000 2003-08-08 00:00:00.000 NORGE2811698 2003-07-20 00:00:00.000 2003-08-08 00:00:00.000 NORGE2811789 2003-07-07 00:00:00.000 2003-08-04 00:00:00.000 ÅLAND2812068 2003-07-10 00:00:00.000 2003-09-04 00:00:00.000 ITALIEN2812236 2003-07-07 00:00:00.000 2004-01-07 00:00:00.000 FRANKRIKE2812361 2003-07-04 00:00:00.000 2003-07-27 00:00:00.000 DANMARK2812436 2003-08-01 00:00:00.000 2003-10-31 00:00:00.000 FRANKRIKE2812534 2003-07-08 00:00:00.000 2003-08-14 00:00:00.000 U.S.A.2812834 2003-07-15 00:00:00.000 2004-01-15 00:00:00.000 FÖRENADE ARABEMIRATEN2813563 2003-07-13 00:00:00.000 2003-08-06 00:00:00.000 ÅLAND2814676 2003-07-18 00:00:00.000 2003-08-12 00:00:00.000 FINLAND2815342 2003-07-08 00:00:00.000 2003-07-28 00:00:00.000 TYSKLAND2816137 2003-07-10 00:00:00.000 2003-09-23 00:00:00.000 PORTUGAL...I´m am then trying to get at resultset that counts the number of records andpresents an output like:[Country], [Datediff 1-14 days], [Datediff 15-30 days], [Datediff > 30 days]I will have it groupt by Country. Can I do that in a single question or do I have to use temp tables?>>>Kim |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
|
|
|
|