624 reputation
37
bio website
location
age
visits member for 3 years, 1 month
seen Jul 29 at 22:34

Sep
13
awarded  Yearling
Jun
25
awarded  Popular Question
Sep
13
awarded  Yearling
Sep
13
awarded  Yearling
Oct
5
comment Two relationships to same table
It's a variation of the same pattern. Take the various customer ids out of the transaction table and put them in a junction table that has transaction id, customer id, and customer type id if necessary.
Oct
5
answered How to get dependencies order
Oct
5
comment Two relationships to same table
It depends on the rules. If a transaction can only have one customer, stick the customer id in the transaction table. If transactions can have multiple customers, create a customer_transaction table with the customer id and the transaction id. The customer type should not be a part of the junction between transactions and customers...it shouldn't matter to the transaction at all if the customer has only one type, or six.
Oct
5
comment Two relationships to same table
@Ezi, why six jump tables? One contact_type table, one contact table, one contact_type_xref table to relate the contacts to the types. One record per contact in the contact table, 6 records per contact in the contact_type_xref table, one record per contact in the contact type table. It probably wouldn't hurt to read up on database normalization.
Oct
5
revised Two relationships to same table
Added example
Oct
5
answered Two relationships to same table
Oct
4
comment Multiple operations using WITH
Arg, I'm dumb...didn't see the Oracle tag. I'm sure that @JackDouglas answer is more on the spot.
Oct
4
comment Multiple operations using WITH
@BrunoLM, edited for example
Oct
4
answered Multiple operations using WITH
Sep
23
answered How do I backup SQL Server Agent configuration?
Sep
22
revised Is there a way to have SQL Server format a number into ordinal form?
added 216 characters in body
Sep
22
answered Is there a way to have SQL Server format a number into ordinal form?
Sep
22
comment why does my pivot give me an error?
@kacalapy, check the edited query. Without sample data as @jcolebrand pointed out it's hard to tell why it returns NULLS. However, in general with a PIVOT the inner SELECT needs to contain all of the fields you need in the PIVOT. One of those fields must be used in an aggregate within the PIVOT statement. Another field must be used after the FOR to designate the fields that are used to PIVOT. Neither of those fields may be used in the outer SELECT - instead, the values you place in the brackets will appear as columns, with the aggregate for values.
Sep
22
awarded  Editor
Sep
22
revised why does my pivot give me an error?
Edited query based in OP feedback
Sep
22
answered why does my pivot give me an error?