Wednesday, March 21, 2012
Need some help regarding duplicate values....
I am using access database and cystal reports XI. Since I am facing some problems.
The following are the details:
Table1 = Sales
Table2 = Collections
Sales (table fields):
1. CustomerName
2. InvoiceNumber
3. InvoiceDate
4. InvoiceAmount
Collections (table fields):
1. CustomerName
2. DepositDate
3. ReceivedAmount
I need these fields in a report. There is no relationship in the database for the CustomerName field.
I tried my best to get the report. But there are repeated values (Duplicate values which are not existing in the table/database) present on the report. Beside to the date values there shows 00:00:00 (time) as well which I dont need.
How to solve this problem. Please help.
Sweetie.The following jpg file shows the duplicate/repeated data.|||Make sure "select Distinct Records" is turned on under the Database menu.|||Make sure "select Distinct Records" is turned on under the Database menu.
Hi, thought I have selected the option "select Distinct Records" the same thing happens that the data in collections.AmountReceived repeats.
Any further help please. (Using Crystal Reports XI).
Sweetei.|||click on database menu, select database expert and go to link tab.
drag customername from one table to other to make a link.
then u will have a join which ensures data is not repeated.|||click on database menu, select database expert and go to link tab.
drag customername from one table to other to make a link.
then u will have a join which ensures data is not repeated.
Hi, Raheem! I did the same as you have advised but it didn't work. Actually though the both Sales & Collections have CustomerName field but there is no relationship between them in the database.
Could you please help me out of this problem?
Sweetie.|||Hello Sweetie,
It was not the CR code problem, it's your database structure.
While you try to connect the Sales table to the Collection table using CustomerName (seems like the only relationship you can make between the 2), every distinct record in the Sales table will connect to all records in the Collection table which has the same CustomerName. If you look at the DepositDate on your report, you'll see the pattern. It looks like a duplicate problem. In deed, it just a coincident that for each of the 3 customers, you have 2 records in the Collection table.
You can check this out by adding another record for one of the 3 customers in your Collection table. You'll see your report showing triplicate for this customer.
Now before I can help you to solve the problem, you'll need to be more specific about what you're looking for:
1. For each of the customers, you need a balance between Invoice Amount & AmountReceived? If this is the case, then you'll have to make either one a subreport to the other, using CustomerName as a link.
2. If a collection has to refer to an invoice, you must have an InvoiceNumber field in your Collection table. Use both CustomerName & InvoiceNumber to link the 2 tables.|||Hello Sweetie,
It was not the CR code problem, it's your database structure.
Now before I can help you to solve the problem, you'll need to be more specific about what you're looking for:
1. For each of the customers, you need a balance between Invoice Amount & AmountReceived? If this is the case, then you'll have to make either one a subreport to the other, using CustomerName as a link.
2. If a collection has to refer to an invoice, you must have an InvoiceNumber field in your Collection table. Use both CustomerName & InvoiceNumber to link the 2 tables.
Hi, thanks for your kind help. Actually I need the both ways you have mentioned above. But I need to know it step by step to understand easily.
So, Could you please let me know the first way .... ?
"1. For each of the customers, you need a balance between Invoice Amount & AmountReceived? If this is the case, then you'll have to make either one a subreport to the other, using CustomerName as a link."
Sweetie.|||Sweetie, problem is with your database.
even if u join customername and salesperson u will get duplicate, u need to
include some distinguishing column in collection table, maybe invoice no. on which amount is collected.|||Sweetie, problem is with your database.
even if u join customername and salesperson u will get duplicate, u need to
include some distinguishing column in collection table, maybe invoice no. on which amount is collected.
Hi, Raheem. Thanks for the advise. But the problem is, assume that if the customer doesn't pay the full payment for each invoice and pay it in 3 installments and by the time he contines purchasing some items (means he will have another 1 - 2 invoices before he pay the first invoice amount). Then it will be messed.
The example is attached.
Regards,
Seema.|||Hi Seema,
Use FIFO method of adjustment i.e, payments shd be updated in same invoice until balance is 0 then adjust remaining amount with next invoice.
Raheem|||Hi Seema,
Use FIFO method of adjustment i.e, payments shd be updated in same invoice until balance is 0 then adjust remaining amount with next invoice.
Raheem
Wow! is it ? Actually what I needed for my program is the same. This is the first time that I heard about that method. Could you please explain me in detail, only if you dont mind?
Seema_S|||when i get free i will reply you.|||when i get free i will reply you.
Hi, Raheem!
I feel happy to get your reply which can solve my problem.
Thanks in advance.
Sweetie.|||Hi, guys!
I am waiting for the reply to my querry. Could somebody help me in this regard?
Sweetie.|||Sweetie,
I see you've been patiently waiting for over two weeks now!
It has to be said that the 'database' structure is a problem and very prone to errors.
One such error is the city 'JAYPUR' in Collections when it's 'JAIPUR' in Customers and Sales - explains the lack of duplication for that customer!
And what's the FileNumber column in Sales and Collections about? It seems to uniquely identify a customer but this isn't on the customer table. Messy.
You might want to consider ditching all the duplicated rubbish and putting the CustomerID into the Sales and Collections tables at least.
I've knocked together something I think is more like what you're after.See the attached report.
It assumes that the customer name is unique. If you put the CustomerID into the tables then you should use that instead as it really is (should be) unique.
Anyway, have a play with it to see what it does and how. Hope it's of some use.|||Sweetie,
I see you've been patiently waiting for over two weeks now!
It has to be said that the 'database' structure is a problem and very prone to errors.
Anyway, have a play with it to see what it does and how. Hope it's of some use.
Hi,
Thanks for your kind help. I am happy that at last I got my querry answered. There is one problem which is attached as jpg file.
Thanks again.
Sweetie.|||But that's the point - as you have stated before, there is no correlation between sales and collections.
The collections of 17,000 and 4,000 are applied in a First In First Out (FIFO) process to the sales (invoices).
The first invoice (103) was for 8,000 and the second invoice (109) was for 17,000.
The first collection was 17,000 so 8,000 of this is applied to invoice 103.
The remaining 9,000 is left over and applied to the next invoice, 109.
The next collection was for 4,000 and is also applied to invoice 109.
If you want to make it clear that a single collection has been split over multiple invoices then you might want to add the original collection amount / collection id to the report.|||But that's the point - as you have stated before, there is no correlation between sales and collections.
Thanks. It is better that it should show the full amount received.
Regards.
Sweetie.|||Hi sweetie,
i was busy all these days,i am attaching ur database zip file check it.
In Collections table, I added invoice number in it and check two
queries. JaganEllis did the same thing. if u remove invoice date then u will get correct collections amounts displayed.
collecionn 1 for 4000 adjusted in 105
collection 2 for 2000 adjusted in 105
collection 3 for 5200 adjustted in 105 and 111
so if u want to omit invoice date, then u can use query2 to make ur report ..else u u can use query1..
Atlast Hope I helped you.
Raheem|||Hi sweetie,
i was busy all these days,i am attaching ur database zip file check it.
Raheem
Thanks for your kind help. I need to learn more about Normalizing database and Crystal reports. If you know any good tutorials site for the above, plz let me know.
Regards.
Sweetie.sql
Wednesday, March 7, 2012
Need infos regarding install of SQL Express 2005 SP1
Hi,
A little technical question. If I want to install SQL Express 2005 SP1, do I have to uninstall current version first?
Thanks in advance,
Stphane
No, you apply a service pack to an existing installation.|||Hi again,
Thanks for the info. Maybe a last question. Considering the fact that a SP1 has also been issued for Visual Studio 2005, must I first install the SP1 for VS 2005 before installing SP1 for SQL Express 2005 or it doesn't matter?
Thanks for your help,
Stphane
|||It doesn't matter.
Mike
|||SQL Server and Visual Studio are separate products. You do not have to apply SP1 to them in any particular order, nor do you have to apply it to both (though it is a good idea.)
Please indicate if your question has been answered properly. Thanks,
|||Hi again,
I just finished install VS 2005 Sp1. Quite long, especially the section where it was evaluating the pre-requisites, but everything completed without error. It detected the appropriate version of VS2005 I was using. Now I'm ready to apply SP1 to SQL Server Express 2005. Before going on, I really need to clarify those things.
Considering the fact that the version of SQL Server Express 2005 actually present on my system is the one I originally installed from VS2005 Standard disks, what is the appropriate install sequence I should take?:
1- If I want to install "Microsoft SQL Server 2005 Express Edition with Advanced Services", do I have to uninstall the SQL Server Express 2005 version actually installed on my machine first or do I simply install the new one over it?
ref: http://www.microsoft.com/downloads/details.aspx?familyid=4C6BA9FD-319A-4887-BC75-3B02B5E48A40&displaylang=en
2- I presume that I can then install "Microsoft SQL Server 2005 Express Edition Toolkit" without problem. Anything I should take care of before install?
ref: http://www.microsoft.com/downloads/details.aspx?FamilyID=3c856b93-369f-4c6f-9357-c35384179543&DisplayLang=en
3- Finally, I presume that I can apply SP1 "Microsoft SQL Server 2005 Express Edition (SP1)" without any problem. Is the following link the appropriate version to apply or should I apply another one?
ref: http://www.microsoft.com/downloads/details.aspx?familyid=11350B1F-8F44-4DB6-B542-4A4B869C2FF1&displaylang=en
Thanks for your help,
Stphane
|||Stphane,
Your sequence of steps should be work ok.
|||Hi Arnie,
Just to be sure. Must I uninstall current version of SQL Express before going on with others listed in previous message?
Thanks for your help, really appreciated!
Stphane
|||Unless you are using a beta version, you do not need to unInstall before applying the service pack.|||Hi again,
For applying SP1, I was aware that there was no need for uninstalling as I already applied SP1 over Visual Studio 2005. In fact, my question was more about the installation of "Microsoft SQL Server 2005 Express Edition with Advanced Services" over actual SQL Express installed on my machine. Can I install it over actual version or must I first uninstall current SQL Express version installed?
Thanks again,
Stphane
|||
The 'Advanced Services" edition is the same version of SQL 2005 Express, and it includes additional functionality, including Management Studio Express.
Again, you do NOT have to uninstall before adding a service pack.
(Now is that complete enough for you to indicate you have been responded and answered?
|||Hi again,
This last question was not about SP1. Actually the SQL Server 2005 Express version I have is the one installed directly from Visual Studio 2005 Standard Edition disks. I would like before applying SP1 to install instead version/package "Microsoft SQL Server 2005 Express Edition with Advanced Services". During your last posts, you seemed to talk only about SP1. Again, "Microsoft SQL Server 2005 Express Edition with Advanced Services" is NOT installed but I would like to install it before applying SP1.
That is why I asked again, and still ask, in order to install "Microsoft SQL Server 2005 Express Edition with Advanced Services" over current version I have of SQL Express, do I have to uninstall SQL Express version currently installed first?
After this new install will be done, THEN I know I will be able to install SP1 without touching anything, the same way I already did so far for VS 2005.
Sorry for misunderstanding, but I want to be sure before screwing up anything.
Stphane
|||And as I have replied many, many times: NO, you do not have to uninstall your current version of SQL 2005 Express. When you start up the "Advanced Services" edition, you will be asked if you want to install a new instance, or just install the new advanced services and Management Studio Express.
Please, give it a rest. Go make your installation. Go with Peace and Florish.
|||Hi,
Really sorry to bug you but I never went through this install so far. Having known from start that install process would have asked me this question would have made things clear in my mind. Now, with that last detail, YES, we can close the subject.
Thanks for your patience,
Stphane
|||Cool, you gave yourself credit for answering your own question!Need idea about COLLATE
Here is an example. Collate ensures that the CustomerID is compared based on the same collation.
Code Snippet
select c.customer_full_name, count(*) cnt
from customers c join orders o
on c.CustomerID collate Latin1_General_CS_AS = o.CustomerID collate Latin1_General_CS_AS
|||thanks,
It could be helpfull if u explain what is a collate why we should go for collate|||Depending on the collation of a table/database, queries can give different results or may not even work at all (in the case of a join between 2 columns with different collations).
Check out Books Online:
http://msdn2.microsoft.com/en-us/library/ms143726.aspx
HTH!
|||HI,
Could you give example of different collation of table like table structure so that i can work and clarify.
Why i need structure is in the below example i placed "join" in place collate it showed error.when i replaced it to collate it works fine with SQL2000..need help.
Select
c.Version_id,wit.catalog_tour_id,wit.contentsite_id,wit.sequence,wit.dayrange,wit.short_description,wit.long_description,
'Photon',getdate(),'Photon',getdate(),0,wit.itinerary_image,wit.itinerary_image_description
From webeftours..TourItinerary wit(NoLock)
Inner Join CatalogTour c
on wit.Catalog_Tour_id = c.Catalog_tour_id collate SQL_Latin1_General_CP1_CI_AI
WHERE wit.catalog_tour_id in (
'GSJ D'
)
From Books Online:
Code Snippet
USE tempdb
GO
CREATE TABLE TestTab (
id int,
GreekCol nvarchar(10) collate greek_ci_as,
LatinCol nvarchar(10) collate latin1_general_cs_as
)
INSERT TestTab VALUES (1, N'A', N'a')
GO
SELECT *
FROM TestTab
WHERE GreekCol = LatinCol
GO
SELECT *
FROM TestTab
WHERE GreekCol = LatinCol COLLATE greek_ci_as
I would suggest in your case, the defaut collation of the database webeftours is different and incompatible with the database containing CatalogTour.
You can change the collation of a column using ALTER TABLE. You can also change the default COLLATION of a database (ie when a collation is not specified in DDL statements, it takes the database default) though only new objects will have the new collation. You'd have to change existing objects manually.
Thanks,
When i tried to create the table it throws an error(Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'collate'.)..need help
Can you post the statement you are trying to execute?
|||use scratch
go
CREATE TABLE TestTab (
id int,
GreekCol nvarchar(10) collate greek_ci_as ,
LatinCol nvarchar(10) collate latin1_general_cs_as
)
What version of sql server are you running that query on? If 2000 or above, can you check what the result of:
sp_dbcmptlevel 'scratch'
If its 70 or below then that may be your problem.
|||Result i got is"The current compatibility level is 70."|||Ok, you need to update your compatibility level.
If you are running SQL2000 run:
sp_dbcmptlevel 'scratch', 80
This should solve the syntax problem.
Good luck!
|||Collate was introduced in sql2k. So, you'd want to set your data compatibility to 80.
Code Snippet
exec sp_dbcmptlevel 'your_db_name', 80