Re: Advanced SQL - Extracting values by months



On May 29, 12:23 am, "David Cressey" <cresse...@xxxxxxxxxxx> wrote:
"whitsey" <lysterfiel...@xxxxxxxxx> wrote in message

news:1180340909.593482.109010@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Help!

I am trying to write an SQL statement (without much luck) to extract
the total number of searches and orders from a particular customer,
grouped into days/months/weeks (depending on the report type.

The tables are as follows:

Searches
--------------
search_id (PKEY)
customer_id (FKEY)
product_id
cost
date
....

Orders
-----------
order_id (PKEY)
search_id (FKEY)
order_value
date
...

Groups
-----------
group_id (PKEY)
customer_id
...

Customers
---------------
customer_id (PKEY)
....

What I want to achieve from this is

For all customers with Group_id = '17'

Let's stop right here.

Customer_id should not be a column in the Groups table. The way you've
placed it, it looks like a customer can belong to many groups, but a group
can only have one customer in it. I doubt that this is your intent.

More likely would be a "group_id" column in the Customers table. Do you
agree?- Hide quoted text -

- Show quoted text -

I'm not having an issue with the table structure, it is the SQL
required to extract the information I want.

A Group can have multiple customers in it and a customer can be a part
of multiple groups.

.



Relevant Pages

  • Re: Advanced SQL - Extracting values by months
    ... the total number of searches and orders from a particular customer, ... search_id (PKEY) ... customer_id (FKEY) ... working out a correct query is going to be ...
    (comp.databases)
  • Re: Advanced SQL - Extracting values by months
    ... the total number of searches and orders from a particular customer, ... search_id (PKEY) ... customer_id (FKEY) ... INNER JOIN ORDERS ...
    (comp.databases)
  • Re: Advanced SQL - Extracting values by months
    ... I am trying to write an SQL statement to extract ... search_id (PKEY) ... customer_id (FKEY) ... placed it, it looks like a customer can belong to many groups, but a group ...
    (comp.databases)
  • Re: Advanced SQL - Extracting values by months
    ... I am trying to write an SQL statement to extract ... search_id (PKEY) ... placed it, it looks like a customer can belong to many groups, but a group ...
    (comp.databases)
  • Building a multi-tenancy application
    ... Can anyone point me to a article of product about using an application hosted on a webserver for multiple customers? ... So everything is the same except for the connection string each customer runs with, ... File Storage Folder with a folder in which a structue for each client resides ... Is this a keepable structure in performance? ...
    (microsoft.public.dotnet.framework.aspnet)