crystal reports count instance by group then sum - count

My subreport has groupings on Account ID then Invoice No. Within the Account ID I could have several Invoice No's.
For example:
Account 1234
Invoice 6789
Invoice 5432
Invoice 5432
Invoice 9999
What I want is count of invoices. Using the example I should get a count of 3. There are 3 unique invoice numbers under the account id. I have tried a running total, formulas and summary.

Using Distinct Keyword in sql query or linq You Can Solve This Problem.
var data = (from n in tbldemo select n).Distinct();
Now Set data to your crystal report data source. It will helps you.

Related

How to maintain tables when we have multiple customers having single product?

What tables and relationships should I design for an app supporting multiple customers?
I am developing a web application which has multiple customers and a single product. I want daily sales data to be stored for each customer - there are about 10 customers.
My application has a screen where the following data is entered and saved:
Customer Name
Price per quantity
Quantity
Total amount
Amount
Balance
Old Balance
Total Balance
I need to decide how to create tables, the number of tables and the relationships between them. For example, should I have separate tables for each customer? I need the total sales to be maintained in database.
You can have two tables. One customer main table with columns Id,Name
Id can be of identity type which increments for every insert of customer name.
CREATE TABLE Customer(
Id INT IDENTITY(1,1) PRIMARY KEY,
Name VARCHAR(30)
)
Second table can be sales table as there is a single product , you can just have that as a column in this table. Columns for this table would be
id(Again identity primary key for sales table)
Product name
Quantity
Total amount
Amount
Balance
Old Balance
Total Balance
CustomerId (foreign key referencing the customer table)
Also sales date can be added to the sales table, which will be helpful to retrieve sales based on date.
While retrieving, you can use the relationship between the tables to get the customer name.
Hope this information helps.

MS Access find unmatched finds items that should have matched

I have a MS Access database with a table of data from the university accounting system and another table with data from our local invoice system. I want to find the invoices in the local table that are not in the university accounting system table. The invoice number (as text, because our invoice numbers may have text) is my match point between the two tables.
The problem is that some of the unmatched invoice numbers SHOULD have found a match. The numbers appear to be exactly the same in both tables. When I query either table for a specific unmatched invoice number, I find it. The formatting of both table’s invoice number field is the same. An example is invoice number 100512. The same number is in both tables but my query says no match found.

Returning the number of products in a database

I have made a database with the columns, Product, Quantity, Size and Units. There are 4 products in my db. What would I use if I wanted to return the quantity of a product in the database?
Say I have Bread in my products and have a quantity of 5. How would I get my cmd to output that I have 5 loaves of bread?
select quantity, size, units from {table name} where product = 'bread'
That should get you started.
Note that you're using the word database to mean table. A relational database like sqlite contains one or more tables that hold your data in rows

Get a Value from One Cell in Sqlite to Livecode

I am using sqlite as my database. It is connected to the livecode project.
The Contacts table has the following data (address and contact number are omitted for security)
ID Name Address Contact No.
1 John ...Philippines 0999999999
2 Kim ...Philippines 0999999999
When I executed this command...
SELECT Name from Contacts ORDER BY ID DESC LIMIT 1
It will return
Kim
In Livecode, I want to store that value to the variable and display it as a Message Box.
How to do that?
You can use any of LiveCodes database functions. First you need to open the database via:
revOpenDatabase("sqlite",filepath[,sqliteOptions])
Then you can query the database via one of the query commands:
revQueryDatabase(databaseID,SQLQuery[,{variablesList | arrayName}])
There is also a function called revDataFromQuery([columnDelim],[rowDelim],databaseID,SQLQuery[,varsList]) that you might use for your query.
Look them up in your dictionary and you may also have a look at the "Book Database" provided via the start center.
So using the last function you can use:
put revOpenDatabase("sqlite","/path/to/your/database") into tDB
revDataFromQuery(,,tDB,"SELECT Name from Contacts ORDER BY ID DESC LIMIT 1", tResult)
answer tResult
(Using empty row and column delimiter as you only select one field in one post.)

query to fetch same row by different words in sqlite

I am new be in database programming .I have to fetch same row from different where word for example I have 2 column keywords and data in keywords there may be more than one words Profit ,profits,revenue but data column have only one entry
keywords data
Profit, Profits, revenue It is increasing
Now when user enter profit or profits or revenue then he/she get same data " It increasing"
Could you provide me query .
Thanks in advance
Use LIKE: SELECT data FROM table WHERE keywords LIKE '%Profit%';

Resources