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 |
sqldba20
Posting Yak Master
183 Posts |
Posted - 2010-12-19 : 15:07:11
|
Folks:Based on the below mentioned data I would like to know how my query will be:Client 'ABC' wants to know if most users have as their last exposure an Start or a Target and from what site it came. As an output, I would like to see:Site | Number of users who ended with a Target Flag| Number of users who ended with an Start FlagColumns: ID, Client, WebAddress, Date, Investment, UserId, Start_Flag, Target_FlagData: 1 ABC yahoo 2010-01-01 00:00:00.000 Loan 1 1 02 ABC msn 2010-02-01 00:00:00.000 Loan 1 1 03 ABC google 2010-03-01 00:00:00.000 Loan 1 0 14 ABC yahoo 2010-04-01 00:00:00.000 Loan 1 1 05 ABC yahoo 2010-04-02 00:00:00.000 Loan 2 1 06 ABC google 2010-03-02 00:00:00.000 Loan 2 0 17 ABC msn 2010-01-02 00:00:00.000 Loan 1 0 18 ABC bing 2010-01-05 00:00:00.000 Loan 2 0 19 ABC bing 2010-01-04 00:00:00.000 Loan 2 0 19 ABC yahoo 2010-01-04 00:00:00.000 Loan 1 0 110 ABC bing 2010-01-10 00:00:00.000 Loan 1 0 111 ABC bing 2010-01-10 00:00:00.000 Loan 2 0 1 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-12-20 : 04:14:03
|
select Site,count(Start_Flag),count(Target_Flag) from tablewhere Start_Flag=1 OR Target_Flag=1group by SitePBUH |
 |
|
|
|
|