Click here to Skip to main content
15,896,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,
         Table name - rskrplsetting
----------------------------------------------------------------
Pfid | module | Type | rpltype | ltyp  | lvalue | points
----------------------------------------------------------------
pf069|Position|Export|Risk     |Percent|   2    |0.5031000000000
pf069|Cover   |Export|Risk     |Percent|   2    |0.5031000000000
pf069|EEFC    |Export|Risk     |Percent|   2    |0.5031000000000
pf069|Loan    |Loan  |Profit   |Percent|   4    |1.0063000000000
pf069|Swap    |Loan  |Profit   |Percent|   4    |1.0063000000000


I have to retrieve values from table to display in crystal report.
For example:
Pfid | module | Type | RL Type| Percent  | Points | PL Type | Percent | points

ltyp as 'RL Type',lvalue as 'Percent',Points where rpltyp is Risk
ltyp as 'PL Type',lvalue as 'Percent',Points where rpltyp is Profit

In one query I have to do this.
If anybody know to do this please help me.

Thanks in advance
Posted
Updated 16-Mar-12 22:34pm
v2
Comments
André Kraak 17-Mar-12 4:35am    
Edited question:
Added pre tags

You can use the following query
SQL
--Create a Temp table for Risk row values
SELECT Pfid, module, Type, ltyp as [RL Type], lvalue as RPercent, points as RPoints
INTO RT
FROM rskrplsetting
WHERE rpltyp = 'Risk'
--Create a Temp table for Profit row values
SELECT Pfid, module, Type, ltyp as [PL Type], lvalue as PPercent, points as PPoints
INTO PT
FROM rskrplsetting
WHERE rpltyp = 'Profit'
--Combine the rows from Temp tables
SELECT ISNULL(RT.pfid,PT.pfid) as pfid, ISNULL(RT.module,PT.module) as module, ISNULL(RT.Type,PT.Type) as Type,
RT.[RL Type], RT.RPercent, RT.RPoints, PT.[PL Type], PT.PPercent, PT.PPoints
FROM RT FuLL OUTER JOIN PT ON RT.pfid = PT.pfid
DROP TABLE RT, PT
 
Share this answer
 
Comments
Jayanthi-SE 20-Mar-12 5:41am    
Hi,

Thanks a lot
Hi,

I used this coding. It's working.

Dim qry As String = ""
qry = "select c.currency as 'Currency1', s.type as 'type1',s.module as 'module1',s.ltyp as 'RL Type',s.lvalue as 'Percent',s.points,d.pfname from rskrplsetting s inner join comcurrencylist c on s.ccy1=c.curid inner join comportfoliomaster d on s.pfid=d.pfid and s.rpltyp='Risk' and s.pfid='" + ddlpf.SelectedValue + "'"
qry &= "; select ltyp as 'PL Type',lvalue as 'Percent1', points as 'points1' from rskrplsetting where rpltyp='Profit' and pfid='" + ddlpf.SelectedValue + "'" '& getquery(qrytype.PolicySetting)
temds = da.retds(qry, "rskrplsetting", conn)
With temds.Tables
.Item(0).TableName = "DataTable1"
.Item(1).TableName = "rskrplsetting"
End With
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900