Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10482

Re: Array for sub report

$
0
0

hi Sam,

 

you can also do this by using a Command object as your datasource. in the Command object you would use your regular query, and then use a UNION to add a list of all employees to your first query. here's a very simple example of a union that will show all employees even if they didn't have any sales...

 

SELECT

`Employee`.`Employee ID`, `Employee`.`Last Name`, `Employee`.`First Name`, `Orders`.`Order Amount`,  `Orders`.`Invoice Name`
FROM 

`Employee` `Employee` INNER JOIN `Orders` `Orders`

ON `Employee`.`Employee ID`=`Orders`.`Employee ID`

 

UNION ALL

 

SELECT DISTINCT

`Employee`.`Employee ID`, `Employee`.`Last Name`, `Employee`.`First Name`, 0, ''
FROM  

`Employee` `Employee`

 

 

note that the second select is bringing in only the employee info in order to populate a full list of names.

 

it also assigns a value of '0' for the sales. the 0 is to ensure that the number of columns / fields in the first half matches the number of columns & the type in the second half.

 

there is also a '' in the second half representing an empty value for where the "invoice name" field is.

 

so as long as you have the same number of columns in both halves and as long as the types all match (even if you're using dummy values like in the above example) you should have no problem.

 

-jamie



Viewing all articles
Browse latest Browse all 10482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>