Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Monday, March 26, 2012

Grouping by Page Count in CR 8.5

Datasource: Access 2000
CrystalReports: 8.5
Language: Visual Basic 6

I wonder if someone can help with this.

I am have a report that collates customer details and it is currently grouped on customer number.

These details are used to generate mail shots and it is now a requirement that the report is ordered by page count.

Is there a way that the total number of pages printed for each customer number can be used to sort the report.

So far the formulas I have tried cannot be completed because the report needs to generated first so the page numbers can be calculated.

The solution can be either in code or in the report but if in the report I need to be able to obtain the page totals for each customer number into code.

Many thanks in advance.Do you want to know how many pages does Report have for each Customer?sql

Monday, March 12, 2012

Group chart by month

I have a really basic chart that pulls data from a SQL table. I have
the dataset asking for a machine number. The date range is hard coded
in the query for now.
This is my table's basic data...
Machine | Performance | DateTime
____________________________
1125 | 60 | 11/16/06
1125 | 45 | 12/01/06
1125 | 35 | 12/15/06
The results give me all the machines details from sept06 through
feb07. The series is the machine, Y axis is the performace and the X
Axis is the date formated by MM/YY
Right now the chart shows me 3 records. one for 11/06 and two for
12/06. Each record has a bar for the proper performance number.
What I need is 2 records.
11/06 and the bar will represent the avg for all Nov records.
12/06 and the bar will represent the avg for all Dec records.
I'm not sure if I have to change the dataset query or adjust the
groupings or whatever in the table. I'm lost right now."Bruce Lawrence" <BL32375@.gmail.com> wrote in message
news:1170436640.424961.261770@.p10g2000cwp.googlegroups.com...
>I have a really basic chart that pulls data from a SQL
>table. I have
> the dataset asking for a machine number. The date range
> is hard coded
> in the query for now.
> This is my table's basic data...
> Machine | Performance | DateTime
> ____________________________
> 1125 | 60 | 11/16/06
> 1125 | 45 | 12/01/06
> 1125 | 35 | 12/15/06
> The results give me all the machines details from sept06
> through
> feb07. The series is the machine, Y axis is the
> performace and the X
> Axis is the date formated by MM/YY
> Right now the chart shows me 3 records. one for 11/06 and
> two for
> 12/06. Each record has a bar for the proper performance
> number.
> What I need is 2 records.
> 11/06 and the bar will represent the avg for all Nov
> records.
> 12/06 and the bar will represent the avg for all Dec
> records.
> I'm not sure if I have to change the dataset query or
> adjust the
> groupings or whatever in the table. I'm lost right now.
>
I suggest you change the query. You don't mention a primary
key. You need one. You can then filter the data in your SQL
query. May I suggest you ask this question in one of the SQL
Server newsgroups (such as
microsoft.public.sqlserver.newusers, or
microsoft.public.sqlserver.programming) and give them your
full table structure and the query you are using. Include an
example of the results you want and the incorrect results
you are getting now.
Hope this helps.
Ron.

Wednesday, March 7, 2012

GROUP BY not working?

I'm having a really odd problem.. this is basic SQL, so it should be easy for most of you. For some strange reason, the quantity is not being summed up. Any idea why this would be happening? Everything else is grouped. The SQL is below, and some of the results are below that (you can see that it SHOULD be grouping them properly).

SELECT TOP 100 PERCENT dbo.cp_elements.campaign_id, dbo.cp_campaigns.name AS campaign_name, dbo.cp_elements.item_no, dbo.cp_elements.name,
dbo.cp_orderables.est_qty, dbo.cp_orderables.qty_increment, SUM(dbo.cp_order_detail.qty) as qty, dbo.cp_attribs.price
FROM dbo.cp_orderables INNER JOIN
dbo.cp_elements ON dbo.cp_orderables.element_id = dbo.cp_elements.element_id INNER JOIN
dbo.cp_attribs ON dbo.cp_orderables.orderable_id = dbo.cp_attribs.orderable_id INNER JOIN
dbo.cp_order_detail ON dbo.cp_attribs.attrib_id = dbo.cp_order_detail.attrib_id INNER JOIN
dbo.cp_selected_shiptos ON dbo.cp_order_detail.shipto_id = dbo.cp_selected_shiptos.shipto_id INNER JOIN
dbo.cp_campaigns ON dbo.cp_elements.campaign_id = dbo.cp_campaigns.campaign_id
GROUP BY dbo.cp_elements.campaign_id, dbo.cp_campaigns.name, dbo.cp_elements.item_no, dbo.cp_elements.name, dbo.cp_selected_shiptos.state,
dbo.cp_orderables.qty_increment, dbo.cp_attribs.price, dbo.cp_orderables.est_qty
ORDER BY dbo.cp_elements.item_no

RESULTS:
16,Project Z,10S,Ten Spot,10,1,0,9.9900
16,Project Z,10S,Ten Spot,10,1,15,9.9900
16,Project Z,10S,Ten Spot,10,1,0,9.9900

That 2nd from last column is the qty_increment.. it's spitting out 3 rows when it should just show one, with 15 as the qty_increment.

Thanks for any help/clues!Hi,

I noticed that u have missing the dbo.cp_selected_shiptos.state column in SELECT COLUMNS. You have to give all the group by columns in SELECTed columns. Also Group by clause should have the ORDER BY COLUMN. This might be the reason that u face.

U check it out and let me know. for Further,|||AHHHHH!! Duh! Stupid mistake... these are the usual kinds of mistakes I run into :) Nothing complicated or serious, just something really minor.

Thanks for pointing that out :) I removed state from the group by and it works fine now.