Subject | Can this query be achieved? |
---|---|
Author | Lee Jenkins |
Post date | 2003-10-29T15:46:50Z |
I have been playing with doing the following in a query or SP on
serverside for a while now in my spare time, but just cannot seem to get
it and was hoping for some help on this one.
My customers sometimes complain that duplicate groups of items on
kitchen receipts such as the following:
HAMBURGER
+ Mustard
+ Pickles
French Fries
Coleslaw
HAMBURGER
+ Mustard
+ Pickles
French Fries
Coleslaw
HAMBURGER
+ Mustard
+ Pickles
Baked Potato
Coleslaw
As you can see, the first two groups are identical while the last group
is different so the ideal receipt would look like:
HAMBURGER X 2
+ Mustard
+ Pickles
French Fries
Coleslaw
HAMBURGER X 1
+ Mustard
+ Pickles
Baked Potato
Coleslaw
The relevant fields are:
ItemDesc: VarChar
ItemID: Based on an Incremented field for the current sale #
which is reset with each new sale.
ParentID: Integer
Now, if you've noticed the top level item of the group is considered the
"Parent" item. On the client side, if the item being entered is a
Parent Item, then its ParentID field is populated with its own ItemID
field because well, its Parent is itself. Each successive "Childs" item
is stamped with the ItemID of the Parent Item thus:
ItemDesc ItemID ParentID
-------- --------- ----------
HAMBURGER 1 1
+ Mustard 2 1
+ Pickles 3 1
Baked Potato 4 1
Coleslaw 5 1
HAMBURGER 6 6
+ Mustard 7 6
+ Pickles 8 6
Baked Potato 9 6
Coleslaw 10 6
HAMBURGER 11 11
+ Mustard 12 11
+ Pickles 13 11
Baked Potato 14 11
Coleslaw 15 11
Any help or suggestions would be greatly appreciated as this one has
been kicking my butt. ;)
--
Warm Regards,
Lee
--
Warm Regards,
Lee
serverside for a while now in my spare time, but just cannot seem to get
it and was hoping for some help on this one.
My customers sometimes complain that duplicate groups of items on
kitchen receipts such as the following:
HAMBURGER
+ Mustard
+ Pickles
French Fries
Coleslaw
HAMBURGER
+ Mustard
+ Pickles
French Fries
Coleslaw
HAMBURGER
+ Mustard
+ Pickles
Baked Potato
Coleslaw
As you can see, the first two groups are identical while the last group
is different so the ideal receipt would look like:
HAMBURGER X 2
+ Mustard
+ Pickles
French Fries
Coleslaw
HAMBURGER X 1
+ Mustard
+ Pickles
Baked Potato
Coleslaw
The relevant fields are:
ItemDesc: VarChar
ItemID: Based on an Incremented field for the current sale #
which is reset with each new sale.
ParentID: Integer
Now, if you've noticed the top level item of the group is considered the
"Parent" item. On the client side, if the item being entered is a
Parent Item, then its ParentID field is populated with its own ItemID
field because well, its Parent is itself. Each successive "Childs" item
is stamped with the ItemID of the Parent Item thus:
ItemDesc ItemID ParentID
-------- --------- ----------
HAMBURGER 1 1
+ Mustard 2 1
+ Pickles 3 1
Baked Potato 4 1
Coleslaw 5 1
HAMBURGER 6 6
+ Mustard 7 6
+ Pickles 8 6
Baked Potato 9 6
Coleslaw 10 6
HAMBURGER 11 11
+ Mustard 12 11
+ Pickles 13 11
Baked Potato 14 11
Coleslaw 15 11
Any help or suggestions would be greatly appreciated as this one has
been kicking my butt. ;)
--
Warm Regards,
Lee
--
Warm Regards,
Lee