-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: thajeer
Message 2 in Discussion
Hi Rishi,
If
your problem is as simple as getting the rows in cross tab way here is
the solution
select clientNo , sum( case when cat
= 1 then 1 else 0 ) [Flag 1],sum( case when cat = 2 then 1 else 0 ) [Flag
2],sum( case when cat = 3 then 1 else 0 ) [Flag 3]
from <table>
group by clientNo
if its something else which u are looking for .. let me know .. I'll try
my best
Thajeer
"Rishi61" <[EMAIL PROTECTED]>
06/16/2004 04:03 PM
Please respond to
"BDOTNET" <[EMAIL PROTECTED]>
To
"BDOTNET" <[EMAIL PROTECTED]>
cc
Subject
High Priority-Tricky query-
Please respond SQL gurus-
New Message on BDOTNET
High
Priority-Tricky query- Please respond SQL gurus-
Reply
Reply
to Sender Recommend
Message 1 in Discussion
From:
Rishi61
Hi Guys,
Below is the problem description. This is very urgent
as I am sitting on the client side.
SOURCE TABLE S
------------
CLIENT NO TYPE CAT
--------- ----
----
1
A 1
1
B 2
1
B 3
2
A 2
2
B 4
3
D 1
3
B 5
I HAVE TO WRITE A QUERY WHICH WOULD RESULT IN THE FOLLOWING
TARGET TABLE T
------------
CLIENT NO TYPE FLAG1 FLAG2 FLAG3
FLAG4 FLAG5
--------- -----
----- ----- ------
----- --------
1
A 1
0 0
0
0
1
B 0
1
1 0
0
2
A 0
1 0
0
0
2
B 0
0
0 1
0
3
D 1
0 0
0
0
3
B 0
0
0 0
1
I HAVE TO SET THE FLAG IN TARGET TABLE 'T' DEPENDS ON
THE VALUE OF S.CAT
FOR EXAMPLE IF CAT = 2 THEN SET FLAG2 = 1
1.FLAG FIELD CANNOT BE NULL - EITHER 0 OR 1
2.INSERT A ROW IN THE TARGET TABLE FOR EACH CLIENT HAVING
HAVING DIFFERENT HAS TYPE AND UPDATE FLAG IF THE HAS TYPE IS SAME.
3.IF CLIENT RECORD IS NOT IN THE TARGET TABLE THEN 'INSERT' OTHERWISE UPDATE
THE APPROPRIATE FLAG.
Thanks and Regards,
Rishi Girdhar
View
other groups in this category.
Also on MSN:
Start
Chatting |
Listen
to Music |
House
& Home |
Try
Online Dating |
Daily
Horoscopes
To stop getting this e-mail, or change how often it arrives, go to your
E-mail
Settings.
Need help? If you've forgotten your password, please go to Passport
Member Services.
For other questions or feedback, go to our Contact
Us page.
If you do not want to receive future e-mail from this MSN group, or if
you received this message by mistake, please click the "Remove"
link below. On the pre-addressed e-mail message that opens, simply click
"Send". Your e-mail address will be deleted from this group's
mailing list.
Remove
my e-mail address from BDOTNET.
ForwardSourceID:NT0000753E
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]