473,382 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

SQL PRoblem with GROUP BY

11
Item (upc, title, type, category, company, year, sellPrice)
Purchase (receiptId, date, cid, name, card#, expire, expectedDate, deliveredDate)
PurchaseItem (receiptId, upc, quantity)
Stored (name, upc, stock)

To show top selling item: The user provides a date and a number, say n. The system prints a list of the n best selling items on that day, by all the stores. For each best seller, the system shows the title, the company, the current stock and the number of copies sold. The output should be ordered according to sales: the best selling item should be first, the second best will follow, etc.

Here is my SQL code:

Expand|Select|Wrap|Line Numbers
  1. select title, company, sum(stock) as current stock, sum(quantity) as quantity sold
  2. from item, purchase, purchaseitem, stored
  3. where purchaseitem.upc = item.upc AND purchaseitem.receiptID = purchase.receiptID AND
  4. purchaseitem.upc = stored.upc AND date = ?
  5. group by title
  6. order by quantity sold;
  7.  
Can anyone please tell me whether the following is right logically? and also whether it is in right Oracle syntax?

and how do you show the first selling, then the second best selling item ...

Thank you very much for your help.
Nov 26 '07 #1
23 2421
amitpatel66
2,367 Expert 2GB
Hi,

Welcome to TSDN

Please make sure you follow POSTING GUIDELINES when ever you post in the forum

Thanks
MODERATOR
Nov 26 '07 #2
amitpatel66
2,367 Expert 2GB
Item (upc, title, type, category, company, year, sellPrice)
Purchase (receiptId, date, cid, name, card#, expire, expectedDate, deliveredDate)
PurchaseItem (receiptId, upc, quantity)
Stored (name, upc, stock)

To show top selling item: The user provides a date and a number, say n. The system prints a list of the n best selling items on that day, by all the stores. For each best seller, the system shows the title, the company, the current stock and the number of copies sold. The output should be ordered according to sales: the best selling item should be first, the second best will follow, etc.

Here is my SQL code:

Expand|Select|Wrap|Line Numbers
  1. select title, company, sum(stock) as current stock, sum(quantity) as quantity sold
  2. from item, purchase, purchaseitem, stored
  3. where purchaseitem.upc = item.upc AND purchaseitem.receiptID = purchase.receiptID AND
  4. purchaseitem.upc = stored.upc AND date = ?
  5. group by title
  6. order by quantity sold;
  7.  
Can anyone please tell me whether the following is right logically? and also whether it is in right Oracle syntax?

and how do you show the first selling, then the second best selling item ...

Thank you very much for your help.
Firstly,
your query will error out because the alias name used cannot have space in between.
"Current stock" and "quantity sold" cannot have space. if you want a space as you have now you need to enclose them with double quotes but it is not a good programming practice.
Nov 26 '07 #3
amitpatel66
2,367 Expert 2GB
Item (upc, title, type, category, company, year, sellPrice)
Purchase (receiptId, date, cid, name, card#, expire, expectedDate, deliveredDate)
PurchaseItem (receiptId, upc, quantity)
Stored (name, upc, stock)

To show top selling item: The user provides a date and a number, say n. The system prints a list of the n best selling items on that day, by all the stores. For each best seller, the system shows the title, the company, the current stock and the number of copies sold. The output should be ordered according to sales: the best selling item should be first, the second best will follow, etc.

Here is my SQL code:

Expand|Select|Wrap|Line Numbers
  1. select title, company, sum(stock) as current stock, sum(quantity) as quantity sold
  2. from item, purchase, purchaseitem, stored
  3. where purchaseitem.upc = item.upc AND purchaseitem.receiptID = purchase.receiptID AND
  4. purchaseitem.upc = stored.upc AND date = ?
  5. group by title
  6. order by quantity sold;
  7.  
Can anyone please tell me whether the following is right logically? and also whether it is in right Oracle syntax?

and how do you show the first selling, then the second best selling item ...

Thank you very much for your help.
Could you please explain why is your databse table desing such a way?

I would suggest you to place upc,quantity in the purchase table it self rather having seperate table purchaseitem which is not required.

The receipt details will have the item code ie upc and the qty sold, so these two columns can be placed in purchase table.
Nov 26 '07 #4
lionelm
11
Firstly,
your query will error out because the alias name used cannot have space in between.
"Current stock" and "quantity sold" cannot have space. if you want a space as you have now you need to enclose them with double quotes but it is not a good programming practice.
hi there, thank you for your response

here is a modifed sql
Expand|Select|Wrap|Line Numbers
  1. select title, company, sum(stock) as currentstock, sum(quantity) as quantitysold
  2. from item, purchase, purchaseitem, stored
  3. where purchaseitem.upc = item.upc AND purchaseitem.receiptID = purchase.receiptID AND
  4. purchaseitem.upc = stored.upc
  5. group by title;
  6.  
here is the oracle error that i get:
ERROR at line 1:
ORA-00979: not a GROUP BY expression
Nov 26 '07 #5
lionelm
11
Could you please explain why is your databse table desing such a way?

I would suggest you to place upc,quantity in the purchase table it self rather having seperate table purchaseitem which is not required.

The receipt details will have the item code ie upc and the qty sold, so these two columns can be placed in purchase table.
Hi amitpatel66,

I did not read your second reply.

the tables are given in this way and we have to work with those tables.
Nov 26 '07 #6
amitpatel66
2,367 Expert 2GB
Tryh this:

New table structure:

Item (upc, title, type, category, company, year, sellPrice)
Purchase (receiptId, date, cid, name, card#, expire, expectedDate, deliveredDate, upc, quantity)
Stored (name, upc, stock)


Expand|Select|Wrap|Line Numbers
  1. SELECT x.name,i.title,i.company,x.curr_stock,x.qty_sold FROM
  2. (SELECT t.*, row_number() OVER(partition by name ORDER BY name) rn FROM
  3. (SELECT p.name,p.date,p.upc,SUM(s.stock) OVER(PARTITION BY name,upc) curr_stock,SUM(p.quantity) OVER(partition by name,ucd) qty_sold FROM purchase p,stock s
  4. WHERE p.upc = s.upc AND p.name = s.name
  5. ORDER BY p.name,qty_sold DESC) t) x, item i
  6. WHERE x.upc = i.upc
  7. AND rn < = '&1'
  8. AND TO_DATE(x.date,'DD-MON-YYYY') = TO_DATE('&2','DD-MON-YYYY')
  9.  
Note: Query not tested!!
Nov 26 '07 #7
amitpatel66
2,367 Expert 2GB
Hi amitpatel66,

I did not read your second reply.

the tables are given in this way and we have to work with those tables.
Try this query:

Expand|Select|Wrap|Line Numbers
  1. SELECT x.name,i.title,i.company,x.curr_stock,x.qty_sold FROM
  2. (SELECT t.*, row_number() OVER(partition by name ORDER BY name) rn FROM
  3. (SELECT p.name,p.date,p.upc,SUM(s.stock) OVER(PARTITION BY name,upc) curr_stock,SUM(p.quantity) OVER(partition by name,ucd) qty_sold FROM purchase p,stock s,purchaseitem pi
  4. WHERE pi.upc = s.upc AND pi.name = s.name
  5. AND pi.receiptid= p.receiptid
  6. ORDER BY p.name,qty_sold DESC) t) x, item i
  7. WHERE x.upc = i.upc
  8. AND rn < = '&1'
  9. AND TO_DATE(x.date,'DD-MON-YYYY') = TO_DATE('&2','DD-MON-YYYY')
  10.  
Note: Not tested!!
Nov 26 '07 #8
lionelm
11
Try this query:

Expand|Select|Wrap|Line Numbers
  1. SELECT x.name,i.title,i.company,x.curr_stock,x.qty_sold FROM
  2. (SELECT t.*, row_number() OVER(partition by name ORDER BY name) rn FROM
  3. (SELECT p.name,p.date,p.upc,SUM(s.stock) OVER(PARTITION BY name,upc) curr_stock,SUM(p.quantity) OVER(partition by name,ucd) qty_sold FROM purchase p,stock s,purchaseitem pi
  4. WHERE pi.upc = s.upc AND pi.name = s.name
  5. AND pi.receiptid= p.receiptid
  6. ORDER BY p.name,qty_sold DESC) t) x, item i
  7. WHERE x.upc = i.upc
  8. AND rn < = '&1'
  9. AND TO_DATE(x.date,'DD-MON-YYYY') = TO_DATE('&2','DD-MON-YYYY')
  10.  
Note: Not tested!!
As I have already said, I can not change the tables. This is an assignment and your sql looks very complicated that whas it is in my textbook

can someone please tell me what the grouyby error is?
Nov 26 '07 #9
lionelm
11
Item (upc, title, type, category, company, year, sellPrice)
Purchase (receiptId, date, cid, name, card#, expire, expectedDate, deliveredDate)
PurchaseItem (receiptId, upc, quantity)
Stored (name, upc, stock)

I have the following tables can anyone please tell me what is wrong with my sql statement:

Expand|Select|Wrap|Line Numbers
  1. select title, company, sum(stock) as currentstock, sum(quantity) as quantitysold
  2. from item, purchase, purchaseitem, stored
  3. where purchaseitem.upc = item.upc AND purchaseitem.receiptID = purchase.receiptID AND
  4. purchaseitem.upc = stored.upc
  5. group by title;
  6.  
The user provides a date and a number, say n. The system prints a list of the n best selling items on that day, by all the stores. For each best seller, the system shows the title, the company, the current stock and the number of copies sold. The output should be ordered according to sales: the best selling item should be first, the second best will follow, etc.

Thanks.
Nov 27 '07 #10
amitpatel66
2,367 Expert 2GB
As I have already said, I can not change the tables. This is an assignment and your sql looks very complicated that whas it is in my textbook

can someone please tell me what the grouyby error is?
Since u said that u dont want change in table structure, i have made change in my query to work as per your table structure.
Did you put an effort to test that query in your instance??
I cant test for you because i dont have table structure and data in my instance.
Nov 27 '07 #11
amitpatel66
2,367 Expert 2GB
As I have already said, I can not change the tables. This is an assignment and your sql looks very complicated that whas it is in my textbook

can someone please tell me what the grouyby error is?
You will get GROUP BY ERROR if you dont inclue all the columns that you have in SELECT with GROUP BY clause. you have just included title in GROUP by clause, you also need to include other columns with GROUP BY to make your query atleast exectue without any error.
Nov 27 '07 #12
amitpatel66
2,367 Expert 2GB
Threads MERGED for better management of the FORUM

MODERATOR
Nov 27 '07 #13
amitpatel66
2,367 Expert 2GB
Check out this one:

The query is tested and it works fine for your requirement:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> SELECT i.title "Product Name",y.name "Store Name",y.qty_sold "Qty Sold",y.current_stock "Current Stock",y.upc "Product ID" FROM
  3.   2  (SELECT x.*,ROW_NUMBER() OVER(PARTITION BY name ORDER BY name) rn FROM
  4.   3  (SELECT p.name,sum(pu.qty) QTY_SOLD,SUM(DISTINCT s.stock) CURRENT_STOCK,pu.upc FROM purchase p,pi pu,store s WHERE
  5.   4  p.repid = pu.repid
  6.   5  AND s.upc = pu.upc
  7.   6  AND s.name = p.name
  8.   7  AND TRUNC(p.dat) = TRUNC(&Enter_Date)
  9.   8  GROUP BY p.name,pu.upc
  10.   9  ORDER BY p.name,qty_sold DESC,pu.upc) x) y,item i
  11.  10  WHERE i.upc = y.upc
  12.  11  AND y.rn <= '&Enter_N_best_sell'
  13.  12  ORDER BY y.name
  14.  13  /
  15. Enter value for enter_date: SYSDATE   -- Date for which info is reqd
  16. old   7: AND TRUNC(p.dat) = TRUNC(&Enter_Date)
  17. new   7: AND TRUNC(p.dat) = TRUNC(SYSDATE)
  18. Enter value for enter_n_best_sell: 3 -- Top 3 best sales for each stores
  19. old  11: AND y.rn <= '&Enter_N_best_sell'
  20. new  11: AND y.rn <= '3'
  21.  
  22. Product Name         Store Name            Qty Sold Current Stock Product ID
  23. -------------------- -------------------- --------- ------------- --------------------
  24. PEN                  ABC                          2            10 1
  25. PENCIL               ABC                          6            10 2
  26. RUBBER               ABC                         10            10 3
  27. PEN                  BCD                          6            10 1
  28. PENCIL               BCD                          1            10 2
  29.  
  30. SQL> 
  31.  
  32.  
Nov 27 '07 #14
lionelm
11
dear amitpatel,

Thank for your help but your code is a bit complicated for a newbie like me.

I will show you what I have:
The first block of sql statements gives the right result,
the second sql block also give the right result, but when i join them together i get wrong result and I know what it is happening. Can you please tell me how I can join the two sql blocks so that i get
title company sumofquanitity sumofstock



Please use my own variables.

Expand|Select|Wrap|Line Numbers
  1.  
  2. 1) select title, company, sum(quantity) as quantitysold
  3. from item, purchaseitem
  4. where purchaseitem.upc = item.upc
  5. group by title, company;      {it works}
  6. 2) 2) select title, company, sum(stock) as currentstock
  7. from item, stored
  8. where item.upc = stored.upc
  9. group by title, company) {it also works}
  10. 3) DOES NOT WORK: 3) select title, company, sum(quantity) as quantitysold, sum(stock) as currentstock
  11. from item, purchaseitem, stored
  12. where purchaseitem.upc = item.upc and item.upc = stored.upc
  13. group by title, company; { it does not work}
  14.  
  15.  
Nov 27 '07 #15
amitpatel66
2,367 Expert 2GB
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Nov 27 '07 #16
lionelm
11
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR

sorry, I will do that in future. Will I get a response please?
Nov 27 '07 #17
amitpatel66
2,367 Expert 2GB
dear amitpatel,

Thank for your help but your code is a bit complicated for a newbie like me.

I will show you what I have:
The first block of sql statements gives the right result,
the second sql block also give the right result, but when i join them together i get wrong result and I know what it is happening. Can you please tell me how I can join the two sql blocks so that i get
title company sumofquanitity sumofstock



Please use my own variables.

Expand|Select|Wrap|Line Numbers
  1.  
  2. 1) select title, company, sum(quantity) as quantitysold
  3. from item, purchaseitem
  4. where purchaseitem.upc = item.upc
  5. group by title, company;      {it works}
  6. 2) 2) select title, company, sum(stock) as currentstock
  7. from item, stored
  8. where item.upc = stored.upc
  9. group by title, company) {it also works}
  10. 3) DOES NOT WORK: 3) select title, company, sum(quantity) as quantitysold, sum(stock) as currentstock
  11. from item, purchaseitem, stored
  12. where purchaseitem.upc = item.upc and item.upc = stored.upc
  13. group by title, company; { it does not work}
  14.  
  15.  


If you dont want to find the top N best sell for each store then try this query:

Expand|Select|Wrap|Line Numbers
  1. SELECT i.title,i.company,x.name,x.qty_sold,x.current_stock FROM
  2. (SELECT p.name,sum(pu.qty) QTY_SOLD,SUM(DISTINCT s.stock) CURRENT_STOCK, pu.upc
  3. FROM purchase p,pi pu,store s 
  4. WHERE
  5. p.repid = pu.repid
  6. AND s.upc =pu.upc
  7. AND s.name = p.name
  8. AND TRUNC(p.dat) = TRUNC(&Enter_Date)
  9. GROUP BY p.name,pu.upc
  10. ORDER BY p.name,qty_sold DESC,pu.upc) x , item i
  11. WHERE i.upc = x.upc
  12. ORDER by x.name
  13. /
  14.  
This is simple query which will give you the sell of all the items of all the store on a particular day.

&1 - input parameter (Date)
Nov 27 '07 #18
lionelm
11
hi amitpatel:

Expand|Select|Wrap|Line Numbers
  1. SQL> select * from stored;
  2.  
STORENAME UPC STOCK
-------------------- ---------- ----------
broadway 1 10
broadway 2 10
broadway 3 10
broadway 4 10
ubc 1 10
ubc 2 10
ubc 3 10
ubc 4 10
broadway 11 10
ubc 11 10


Expand|Select|Wrap|Line Numbers
  1. select i.title, i.company, temp.qty_sold, temp.current_stock from
  2. (select p.storename, sum(pu.quantity) qty_sold, sum(s.stock) current_stock, pu.upc
  3. from purchase p, purchaseitem pu, stored s
  4. where p.receiptid = pu.receiptid AND s.upc = pu.upc AND s.storename = p.storename
  5. group by p.storename, pu.upc
  6. order by p.storename, qty_sold DESC, pu.upc) temp, item i
  7. where i.upc = temp.upc
  8. order by temp.storename;
  9.  
Running your sql above, give the right result for quantity sold but not for quantity in stock

each item should have 20 in stock

i think we can not have two aggregate operators in one select statement?

any ideas?
Thanks.
Nov 27 '07 #19
amitpatel66
2,367 Expert 2GB
hi amitpatel:

SQL> select * from stored;

STORENAME UPC STOCK
-------------------- ---------- ----------
broadway 1 10
broadway 2 10
broadway 3 10
broadway 4 10
ubc 1 10
ubc 2 10
ubc 3 10
ubc 4 10
broadway 11 10
ubc 11 10


Expand|Select|Wrap|Line Numbers
  1. select i.title, i.company, temp.qty_sold, temp.current_stock from
  2. (select p.storename, sum(pu.quantity) qty_sold, sum(s.stock) current_stock, pu.upc
  3. from purchase p, purchaseitem pu, stored s
  4. where p.receiptid = pu.receiptid AND s.upc = pu.upc AND s.storename = p.storename
  5. group by p.storename, pu.upc
  6. order by p.storename, qty_sold DESC, pu.upc) temp, item i
  7. where i.upc = temp.upc
  8. order by temp.storename;
  9.  
Running your sql above, give the right result for quantity sold but not for quantity in stock

each item should have 20 in stock

i think we can not have two aggregate operators in one select statement?

any ideas?
Thanks.
If I go back and check your requirement, you said you want the Stock for all the items STORE WISE, SO it will not sum up the STOCK for the same item of different stores.
Please tell me your exact requirement??
Nov 27 '07 #20
amitpatel66
2,367 Expert 2GB
If you need current stock,item title,qty sold for all the items regardless the store from where the item is sold/stocked, then this is the query. the simple one:

Expand|Select|Wrap|Line Numbers
  1. SQL> SELECT title,company,cs "Current Stock",qs "Qty Sold" FROM
  2.   2  (SELECT upc,(SELECT SUM(stock) from store WHERE upc = p.upc) cs ,SUM(qty) qs FROM pi p
  3.   3  GROUP BY p.upc) x,item i
  4.   4  WHERE i.upc = x.upc
  5.   5  /
  6.  
  7. TITLE                COMPANY              Current Stock  Qty Sold
  8. -------------------- -------------------- ------------- ---------
  9. PEN                  COMPANY1                        20         8
  10. PENCIL               COMPANY1                        36         7
  11. RUBBER               COMPANY1                        20        10
  12.  
Nov 27 '07 #21
lionelm
11
dear amipatel,

I don't know how much I should thank you. I also have added a the date field.

Expand|Select|Wrap|Line Numbers
  1. select title, company, cs "currentstock", qs "quantitysold" from
  2. (select upc, (select sum(stock) from stored where upc = pi.upc) cs, sum(quantity) qs from purchaseitem pi, purchase p where pi.receiptid = p.receiptid AND purchasedate = '15-NOV-2007'
  3. group by pi.upc) temp, item i
  4. where i.upc = temp.upc
  5. order by qs DESC;
  6.  
The only think I would like to select let's say the 2 best selling items. ROWNUM<=2

I tried many different ways to put in a where clause ROWNUM<=2 but I get different result.

Thanks alot amitpatel,
Nov 27 '07 #22
lionelm
11
Hi amitpatel,

I got it. I figured it out how to select the top two for ie,

I like to thank you so much for all your help. I am becoming more expert in sql.
Nov 28 '07 #23
amitpatel66
2,367 Expert 2GB
Hi amitpatel,

I got it. I figured it out how to select the top two for ie,

I like to thank you so much for all your help. I am becoming more expert in sql.
We are happy that its working for you now
You are welcome :)
Do POST for any issues in future!!

Amit
Nov 28 '07 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Memduh Durmaz | last post by:
Hi, I'm using DB2 UDB 7.2. Also I'm doing some tests on SQL Server 2000 for some statements to use efectively. I didn't find any solution on Sql Server about WITH ... SELECT structure of DB2. ...
1
by: Cat | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm getting a validation error when I try to restrict the content of nested groups with xs:redefine whereas the same restriction on xs:element's...
4
by: ---- | last post by:
Here are my files (problem follows the code): -------------------------------------------------------------------------- // Group.h #ifndef GROUP_H #define GROUP_H class Group { public:
44
by: Carlos Andr?s | last post by:
Hi everybody. I've got a problem. I'd like to avoid opening a new window when you have pressed the shift key and you click in the left button of the mouse. I've tried the next solution, in the...
16
by: michael | last post by:
Is it possible to get all href URLs contained in a unordered list and place them in an array? Or in fact two different arrays, differently named one for each <ul> group? <ul> <li><a...
2
by: Melissa | last post by:
I have a grouped report that starts a new page at each group. All the field labels for the report are in the group header because there is a subreport in the top part of the report that needs to...
7
by: ChadDiesel | last post by:
Hello everyone, I'm having a problem with Access that I need some help with. The short version is, I want to print a list of parts and part quantities that belong to a certain part group---One...
17
by: Mark | last post by:
I must create a routine that finds tokens in small, arbitrary VB code snippets. For example, it might have to find all occurrences of {Formula} I was thinking that using regular expressions...
3
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
1
by: Bryan | last post by:
A Person can belong to one group. I want to be able to set the group using these two methods: PersonA.Group = GroupA or GroupA.Add(PersonA) In the Set method of Person.Group, the Person...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.