PyDeveloper
PyDeveloper

Reputation: 319

crystal report images in a row

Looking for a way where after i choose QR codes to print to order them like this and save to .pdf file

Is my only option for doing that Crystal report ? I'm looking for someone to tell me which way go and get something like this.

enter image description here

and not like this

enter image description here

Upvotes: 0

Views: 227

Answers (1)

user8608631
user8608631

Reputation:

Use the following SQL Query:

WITH CTE
AS
(
    SELECT CodeQ, ROW_NUMBER() OVER(ORDER BY NEWID()) AS RN
    FROM QRCodes
), Parsed
AS
(
    SELECT 
      RN5,
      MAX(Image1) AS Image1, MAX(Image2) AS Image2, MAX(Image3) AS Image3, 
      MAX(Image4) AS Image4, MAX(Image5) AS Image5
    FROM
    (
        SELECT
          ceiling(RN/5.0) AS RN5,
          CASE WHEN RN%5 = 1 THEN CodeQ END AS Image1, 
          CASE WHEN RN%5 = 2 THEN CodeQ END AS Image2, 
          CASE WHEN RN%5 = 3 THEN CodeQ END AS Image3, 
          CASE WHEN RN%5 = 4 THEN CodeQ END AS Image4, 
          CASE WHEN RN%5 = 0 THEN CodeQ END AS Image5 
        FROM CTE
    ) AS t
    GROUP BY RN5
)
SELECT Image1, Image2, Image3, Image4, Image5
FROM Parsed;

This will give you the images in 5 columns. Then build your report to display these 5 columns.


Update:

To make it 4 columns instead of 5, try this:

WITH CTE
AS
(
    SELECT CodeQ, ROW_NUMBER() OVER(ORDER BY NEWID()) AS RN
    FROM QRCodes
), Parsed
AS
(
    SELECT 
      RN4,
      MAX(Image1) AS Image1, MAX(Image2) AS Image2, MAX(Image3) AS Image3, 
      MAX(Image4) AS Image4
    FROM
    (
        SELECT
          ceiling(RN/4.0) AS RN4,
          CASE WHEN RN%4 = 1 THEN CodeQ END AS Image1, 
          CASE WHEN RN%4 = 2 THEN CodeQ END AS Image2, 
          CASE WHEN RN%4 = 3 THEN CodeQ END AS Image3, 
          CASE WHEN RN%4 = 0 THEN CodeQ END AS Image4
        FROM CTE
    ) AS t
    GROUP BY RN4
)
SELECT Image1, Image2, Image3, Image4
FROM Parsed;

Upvotes: 1

Related Questions