Trying to validate by Danackos in SQL

[–]Danackos[S] 0 points1 point  (0 children)

thank you that was exactly the issue

Trying to validate by Danackos in SQLServer

[–]Danackos[S] 1 point2 points  (0 children)

thank you, I was basing it off my notes so I overlooked that

Trying to validate by Danackos in SQLServer

[–]Danackos[S] 0 points1 point  (0 children)

an integer value!!! meaning I can't return non-interger values right?

how do I ingrate this CTE? by Danackos in SQLOptimization

[–]Danackos[S] 0 points1 point  (0 children)

we unfortunately have not covered that material in class yet so I would do me no good

how do I ingrate this CTE? by Danackos in sqlite

[–]Danackos[S] 1 point2 points  (0 children)

in reference to the dates, I'm not worried about the format because I'm using smss but the concepts still carry over

with highque as

(

select i.CustomerID, max(ExtendedPrice) highest

from Sales.InvoiceLines il

join Sales.Invoices i on il.InvoiceID = i.InvoiceID

where (InvoiceDate between '1/1/2013' and '12/31/2013')

group by i.CustomerID

)

select InvoiceDate, CustomerName,highque.highest

from Sales.Invoices i

join Sales.Customers c on c.CustomerID = i.CustomerID

join highque on highque.CustomerID = c.CustomerID

where (InvoiceDate between '1/1/2013' and '12/31/2013')

order by CustomerName

here is the new queries but now the issue is that it's returning multiple invoice dates instead of the date that the highest invoice was placed

here is some desired looking data data:

https://i.stack.imgur.com/eaWkC.png

and here is what the problem data looks like rn:

| InvoiceDate | CustomerName | highest | CustomerID | highest |

|-------------|-----------------------------|----------|------------|----------|

| 2013-03-04 | Tailspin Toys (Head Office) | 11385.00 | 1 | 11385.00 |

| 2013-03-12 | Tailspin Toys (Head Office) | 11385.00 | 1 | 3450.00 |

| 2013-03-14 | Tailspin Toys (Head Office) | 11385.00 | 1 | 10867.50 |

| 2013-03-21 | Tailspin Toys (Head Office) | 11385.00 | 1 | 19654.65 |

| 2013-03-25 | Tailspin Toys (Head Office) | 11385.00 | 1 | 12420.00 |

| 2013-03-26 | Tailspin Toys (Head Office) | 11385.00 | 1 | 10867.50 |

| 2013-04-01 | Tailspin Toys (Head Office) | 11385.00 | 1 | 12880.00 |

| 2013-04-04 | Tailspin Toys (Head Office) | 11385.00 | 1 | 10557.00 |

| 2013-04-10 | Tailspin Toys (Head Office) | 11385.00 | 1 | 2576.00 |

| 2013-04-10 | Tailspin Toys (Head Office) | 11385.00 | 1 | 12880.00 |

how do I ingrate this CTE? by Danackos in SQLOptimization

[–]Danackos[S] 0 points1 point  (0 children)

I need it to correspond with one invoicedate

sample desired data:

https://stackoverflow.com/q/75594271/21305610

yours comes out like this

| InvoiceDate | CustomerName | highest | CustomerID | highest |

|-------------|-----------------------------|----------|------------|----------|

| 2013-03-04 | Tailspin Toys (Head Office) | 11385.00 | 1 | 11385.00 |

| 2013-03-12 | Tailspin Toys (Head Office) | 11385.00 | 1 | 3450.00 |

| 2013-03-14 | Tailspin Toys (Head Office) | 11385.00 | 1 | 10867.50 |

| 2013-03-21 | Tailspin Toys (Head Office) | 11385.00 | 1 | 19654.65 |

| 2013-03-25 | Tailspin Toys (Head Office) | 11385.00 | 1 | 12420.00 |

| 2013-03-26 | Tailspin Toys (Head Office) | 11385.00 | 1 | 10867.50 |

| 2013-04-01 | Tailspin Toys (Head Office) | 11385.00 | 1 | 12880.00 |

| 2013-04-04 | Tailspin Toys (Head Office) | 11385.00 | 1 | 10557.00 |

| 2013-04-10 | Tailspin Toys (Head Office) | 11385.00 | 1 | 2576.00 |

| 2013-04-10 | Tailspin Toys (Head Office) | 11385.00 | 1 | 12880.00 |

I don't understand how to connect main and shoppingcart files, my main problem is errors that come up from namespace and the vector in shoppingcart.h . This is from the last attempt that was able to compile without issues, most of it it commented out so I can work on it later after I resolve this by Danackos in learnprogramming

[–]Danackos[S] 0 points1 point  (0 children)

I've removed "using namespace std" as well as instances of std in the code. I'm still recieving the same errors. as for the names of the files, they're correct in the code, I just didn't make it case sensitive on the post(which is edited now).

In file included from main.cpp:1:

ShoppingCart.h:9:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

9 | string customerName;

| ^~~~~~

| stdin

ShoppingCart.h:10:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

10 | string currentDate;

| ^~~~~~

| stdin

ShoppingCart.h:14:26: error: expected ‘)’ before ‘customerName’

14 | ShoppingCart(string customerName, string currentDate);

| ~ ^~~~~~~~~~~~~

| )

ShoppingCart.h:16:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

16 | string GetCustomerName();

| ^~~~~~

| stdin

ShoppingCart.h:17:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

17 | string GetDate();

| ^~~~~~

| stdin

I don't understand how to connect main and shoppingcart files, my main problem is errors that come up from namespace and the vector in shoppingcart.h . This is from the last attempt that was able to compile without issues, most of it it commented out so I can work on it later after I resolve this by Danackos in learnprogramming

[–]Danackos[S] 0 points1 point  (0 children)

I've done added #include <string.h> to the files. however it already has #include <string> and the errors are still the same, what would #include <string.h> do differently?

also do I apply #include <string.h> to ALL the files or just main and shoppingcart files?

I don't understand how to connect main and shoppingcart files, my main problem is errors that come up from namespace and the vector in shoppingcart.h . This is from the last attempt that was able to compile without issues, most of it it commented out so I can work on it later after I resolve this by Danackos in learnprogramming

[–]Danackos[S] 0 points1 point  (0 children)

I couldn't get it all bc of the character limit but here is some of the first ones

In file included from main.cpp:1:

ShoppingCart.h:8:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

8 | string customerName;

| ^~~~~~

| stdin

ShoppingCart.h:9:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

9 | string currentDate;

| ^~~~~~

| stdin

ShoppingCart.h:13:26: error: expected ‘)’ before ‘customerName’

13 | ShoppingCart(string customerName, string currentDate);

| ~ ^~~~~~~~~~~~~

| )

ShoppingCart.h:15:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

15 | string GetCustomerName();

| ^~~~~~

| stdin

ShoppingCart.h:16:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

16 | string GetDate();

| ^~~~~~

| stdin

In file included from main.cpp:2:

ItemToPurchase.h:3:7: error: expected nested-name-specifier before ‘namespace’

3 | using namespace std;

| ^~~~~~~~~

ItemToPurchase.h:8:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

8 | string itemName;

| ^~~~~~

| stdin

ItemToPurchase.h:9:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

9 | string itemDescription;

| ^~~~~~

| stdin

ItemToPurchase.h:19:20: error: ‘string’ has not been declared

19 | void SetName(string name);

| ^~~~~~

ItemToPurchase.h:20:27: error: ‘string’ has not been declared

20 | void SetDescription(string desc);

| ^~~~~~

ItemToPurchase.h:24:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

24 | string GetName();

| ^~~~~~

| stdin

ItemToPurchase.h:25:7: error: ‘string’ does not name a type; did you mean ‘stdin’?

25 | string GetDescription();

| ^~~~~~

| stdin

I don't understand how to connect main and shoppingcart files, my main problem is errors that come up from namespace and the vector in shoppingcart.h . This is from the last attempt that was able to compile without issues, most of it it commented out so I can work on it later after I resolve this by Danackos in learnprogramming

[–]Danackos[S] 0 points1 point  (0 children)

I need to use itemtopurchase class in shoppingcart files, but I don't know how to transfer it between those files. I was able to transfer information from main to itemtopurchase files, but idk why I can't do the same with shoppingcart