Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
tranquilraven
Starting Member
19 Posts |
Posted - 2012-06-07 : 14:53:03
|
UPDATE: The values seem to be Y and NULL. It isn't a boolean value after all, it is a varchar. Now I really don't understand why my query won't run.I am trying to limit the records based on whether or not the payment has declined. This query does not throw an error but does nto pull any records even though I know there are records that don't have the paymentdeclined set to Y. The paymentdeclined is set as a boolean in the database. Can anyone please supply a second set of eyes and tell me what I am screwing up.Thanks so muchSELECT OrderDate AS 'Order Date', PaymentAmount AS 'Total Payments', TotalShippingCost AS 'Shipping Received', SalesTax1 AS 'Sales Tax Received', PaymentDeclined AS ' Payment Declined'FROM OrdersWHERE PaymentDeclined <> 'Y'ORDER BY OrderDate DESC |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-06-07 : 15:09:43
|
| SQL doesn't have boolean values, only values that the user can interpret as true or false.Do SELECT DISTINCT PaymentDeclined FROM Orders, and see what the values are. That's what you'll have to usein your query.JimEveryday I learn something that somebody else already knew |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-06-07 : 15:21:00
|
| [code]SELECT OrderDate AS 'Order Date', PaymentAmount AS 'Total Payments', TotalShippingCost AS 'Shipping Received', SalesTax1 AS 'Sales Tax Received', PaymentDeclined AS ' Payment Declined'FROM OrdersWHERE PaymentDeclined = CAST(0 AS BIT)ORDER BY OrderDate DESC[/code] |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-06-07 : 16:50:18
|
Probably becuase any value comapred to NULL equals UNKNOWN. Try this:SELECT OrderDate AS 'Order Date', PaymentAmount AS 'Total Payments', TotalShippingCost AS 'Shipping Received', SalesTax1 AS 'Sales Tax Received', PaymentDeclined AS ' Payment Declined'FROM OrdersWHERE PaymentDeclined IS NULLORDER BY OrderDate DESC |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-06-07 : 16:50:45
|
WHERE isnull(PaymentDeclined,'') <> 'Y' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
tranquilraven
Starting Member
19 Posts |
Posted - 2012-06-07 : 17:09:15
|
You Rock Lamprey, and thank you for the explanation as well.quote: Originally posted by Lamprey Probably becuase any value comapred to NULL equals UNKNOWN. Try this:SELECT OrderDate AS 'Order Date', PaymentAmount AS 'Total Payments', TotalShippingCost AS 'Shipping Received', SalesTax1 AS 'Sales Tax Received', PaymentDeclined AS ' Payment Declined'FROM OrdersWHERE PaymentDeclined IS NULLORDER BY OrderDate DESC
|
 |
|
|
|
|
|
|
|