Sql stored procedure to get result set separately

2019-06-14 20:30发布

问题:

I am using stored procedure to display my data in Jquery data tables. I wanted to display each result set separately. Here is the example of my code for individual result set.

    select
LEVEL,
PART_NO,
PART_NAME,
L1QTY,
PL1,
PL2,
PL3,
SupplierLocID,
Discrepancies,
Comments
from bomStructuredImportTgt
where len(PL1) > 2
and PL1 = '030480' or PL2 = '030480' or PL3 = '030480'

This is the output for the stored procedure. I am trying to get the same result set but for each of the PL1 values.

LEVEL   PART_NO          PART_NAME             L1QTY  PL1      PL2  PL3 
   2    90001-PM3 -0031  BOLT DRAIN PLUG        1    030480     AE  NULL        
   0    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    030480     BF  NULL
   1    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    030480     FF  NULL

This is how I have the data in my table right now.

LEVEL   PART_NO          PART_NAME             L1QTY  PL1      PL2  PL3 
   2    90001-PM3 -0031  BOLT DRAIN PLUG        1    110630     AE  NULL        
   0    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    JN9999     BF  NULL
   1    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    SO9399     FF  NULL
   2    90001-PM3 -0031  BOLT DRAIN PLUG        1    030480     AE  NULL        
   0    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    030480     BF  NULL
   1    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    030480     FF  NULL

This is how I need the data to be resulted for each PL1.

for 110630

LEVEL   PART_NO          PART_NAME             L1QTY  PL1      PL2  PL3 
   2    90001-PM3 -0031  BOLT DRAIN PLUG        1    110630     AE  NULL 

for JN9999

LEVEL   PART_NO          PART_NAME             L1QTY  PL1      PL2  PL3 
   0    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    JN9999     BF  NULL

for SO9399

LEVEL   PART_NO          PART_NAME             L1QTY  PL1      PL2  PL3 
   1    90040-P8A -A011- M1 BOLT ASSY, DRAIN P  1    SO9399     FF  NULL