Visually Group the Results of a SELECT Statement - sql-server-2008

I want to know how to visually group the results of a SELECT statement.
I don't mean the GROUP BY clause in which I have the count or sum of similar values.
Let's say I have a table A with columns CustId, OrderId, Date, Amount and I do a SELECT * FROM A ORDER BY CustId, Date.
I want to see all records, but I want to kind off break with a line, or an empty row each time there is a change in CustId.
Of course I could export to Excel, but...
Thanks!

I think the practical/helpful answer is "You can't". It's not common to format your result in sql, assuming you mean like you want row breaks inside Sql Server Management Studio in the results pane. Usually you make visual presentation through separate reporting tools. Crystal Reports, Sql Server Reporting Services. The thing is, what you see in the results pane is all data. The only way to add "line break" type visual effects in the results pane is to arrange for them to be part of the data.
Maybe there are other clients that have some kind of support for that. I'm not sure what all you can do with excel by way of formatting when it's connected to a data source, and keeping the connection to the datasource.

Related

How do I fix data is splitting between two groups with the same project number?

I've created a simple report to show customer invoices based on project number. I grouped it by project number. When I run the report, I see two groups for the same project number. I'm fairly new to Reporting Services, so I'm not sure what to do to fix it!
Report sample:
Report Layout:
Report Layout
Query Data:
Sample Query Data
Check your rowgroup properties have grouping just on Project Number.
Also check that the project numbers are in fact the same, it might be you have instances where there are leading or trailing spaces.
To check this do a quick query on the table such as
SELECT DISTINCT ProjectNumber FROM myTable WHERE ProjectNumber LIKE ('%999-10%')
If this comes back with more than one result then either
Change your dataset set query trim the column with something like
SELECT LTRIM(RTRIM(ProjectNumber)) as ProjectNumber, myOtherFields FROM myTable
Change your textbox that displays the project number and the row group properties to =TRIM(Fields!ProjectNumber.Value) (case sensitive column name)
More trouble shooting advice
Everything looks OK, it might be worth even creating a new report from scratch with the minimum steps to reproduce and see if the issue shows up again.
As an additional step, which 'may' give you a clue about what is happening you could append a row number to your dataset query, include that in your report output and then look for a pattern. There are lots of apparently duplicate rows shows in the report so it's difficult to know which is which.
try changing your dataset query to something like
SELECT Phase, JCCo, Job, CostType, ActualDate, Source, Description, ActualHours, ActualUnits, ActualCost,
ROW_NUMBER() OVER(ORDER BY Phase, JCCo, Job, CostType, ActualDate, Source, Description, ActualHours, ActualUnits, ActualCost) as RowNum
FROM bjCCD
Then add the new RowNum field to your report, look for patterns in each group of rows. I'm still convinced that either there is additional grouping or the job field has hidden characters as the report design is very simple there is very little else to go wrong.

Microsoft Access Report Filter / how...?

I have a database to calculate my expenses. I record expenses with negative numbers, and salary with positive numbers. When I make the month report, and sum the values, it sums it all including salary. I want to code of Visual Basic to sum negative numbers only. I know about Filter property, but the Filter I put disappears when I close database. Can you help me, please?
You can build your report using a query or use the Where argument of the OpenReport method of the DoCmd object in versions of Access since 2003.
EDIT re comment
The easiest way to create a query is to use the query designer, viewed in SQL View, you should see something on the lines of:
SELECT Amount
FROM MyTable
WHERE Amount <=0

MS access reports

I created a report using wizard and while creating I selected 4 columns for ordering data in ascending orders. It asked for 4 columns and chose 4 columns and after creation I want to change the preference of the second column to other one. How can I do that??
I cannot see anything in the report query or anywhere else
Ignore any ordering in your report's query source. You can discard your ORDER BY from the query because the Access report will use whatever settings you give it for "Sorting and Grouping" instead.
In Access 2003, with your report in design view, choose View -> Sorting and Group from the Access main menu. If your version of Access is different, look for a similar option.
I should think its just as quick to re-run the whole report. However you can edit the Query that the report is built on.
Or make a query, then get the report to run from the query, this means you can easily change it.

Report rows differ from SQL result

I am stumped.
I have a select statement that returns the data fine in the data pane, but in the resulting report, one row is our of sort order and falls about 25 rows down in the data where it shouldn't be.
How do I trouble shoot something like that?
Thanks!i
Somewhere in the report you must be sorting the dataset. In this case, the data will look fine in the data pane but will be out of the expected order in the report. Try adding a brand new table to the report and apply the dataset. It should match the data pane.
How do I trouble shoot something like that?
You start by posting the select statement here so we can help without having to hone our psychic debugging skills :-)
It's possible that you're not ordering on every column you think you are. It's also possible that SSRS re-orders the data even after you've retrieved it.
They'd be the first two places I'd look.

MS CRM (4.0): Reports - Filtering Imported Reports

I have created a complex report in Microsoft Business Intelligence.
The report has its own (fairly complex) WHERE clause. Is it possible for the user to set the CreatedOn date as part of the criteria?
UPDATE
I was looking at this again. On a basic report (one table) if i import the report over one created with the report wizard, this give you the filter options and works.
On the more complex report that uses the union statement to pull data out of two tables the filter options are available however they have no effect, this is after removing the where clause.
END UPDATE
Thanks
Luke
I have been doing some research into this topic, and it appears that if you alias the fields and prefix them with CRMAF_ this allows you to add filtering. I'm going to look at this over the next few days and see how it works. However it has been noted that several people have been unable to get this to work correctly.
Please note you need to prefix both the table and fields.
You then can set the filter.