| Author |
Topic  |
|
|
oracle_corrgi
Yak Posting Veteran
India
98 Posts |
Posted - 09/04/2006 : 06:22:27
|
hi can any one help with case function with row count
if row count is greater then 1 or >1 case1 if row count is zero then case two
------this is my table and cloumn ---sample code
DECLARE @rc tinyint , @var varchar(50) set @var = (SELECT emd.tpa_id from dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMD where emd.tpa_id=ed.tpa_id and emd.empe_key=ed.division_key) SELECT ed.tpa_id, ed.division_key, emd.tpa_id, emd.empe_key from dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMD
database |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 09/04/2006 : 06:26:30
|
quote: Originally posted by oracle_corrgi
hi can any one help with case function with row count
if row count is greater then 1 or >1 case1 if row count is zero then case two
------this is my table and cloumn ---sample code
DECLARE @rc tinyint , @var varchar(50) set @var = (SELECT emd.tpa_id from dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMD where emd.tpa_id=ed.tpa_id and emd.empe_key=ed.division_key) SELECT ed.tpa_id, ed.division_key, emd.tpa_id, emd.empe_key from dbo.EMPLOYER_DIVISION AS ED,EMPLOYEE_MISC_DATA AS EMD database
IF EXISTS (SELECT * FROM dbo.EMPLOYER_DIVISION AS ED inner join EMPLOYEE_MISC_DATA AS EMD on emd.tpa_id = ed.tpa_id and emd.empe_key = ed.division_key)
SELECT emd.tpa_id
from dbo.EMPLOYER_DIVISION AS ED
inner join EMPLOYEE_MISC_DATA AS EMD on emd.tpa_id = ed.tpa_id and emd.empe_key = ed.division_key
ELSE
SELECT ed.tpa_id,
ed.division_key,
emd.tpa_id,
emd.empe_key
from dbo.EMPLOYER_DIVISION AS ED
cross join EMPLOYEE_MISC_DATA AS EMD
Peter Larsson Helsingborg, Sweden |
 |
|
| |
Topic  |
|
|
|