Thanks to both you and Sylvain. You guys both responded with just about the same way to do this (convert bit to int) so I guess it's how it's done.
Just one more thing: I purposesly made the SELECT short but if I have a lot fields in the Invoice table that I need to retrieve, this means I have to specify every fields I need instead of doing "SELECT A.*..." which would be PITA.
Thanks again.
>You can use T-SQL CASE function to convert bit field into number.
>Also in the select field list you can only use columns listed in group by clause or aggregate functions.
>
>SELECT A.InvoiceID, A.VenID, A.InvDate,
> <b>CASE WHEN A.Closed=1 THEN 1 ELSE 0 END AS Closed</b>,
> B.Vendorname, SUM(C.Subtotal) AS InvoiceTotal
> FROM Invoice A JOIN Vendor B ON A.VenID=B.VenID
> JOIN LineItem C ON A.InvoiceID=C.InvoiceID
> WHERE A.InvoiceID=1000
> GROUP BY A.InvoiceID, A.VenID, <b>B.Vendorname</b>, A.InvDate,
> <b>CASE WHEN A.Closed=1 THEN 1 ELSE 0 END</b>
>
>
>>SELECT A.*, B.Vendorname, SUM(C.Subtotal) AS InvoiceTotal
>>FROM Invoice A JOIN Vendor B ON A.VenID=B.VenID
>>JOIN LineItem C ON A.InvoiceID=C.InvoiceID
>>WHERE A.InvoiceID=1000
>>GROUP BY A.InvoiceID, A.VenID, A.InvDate, A.Closed
>>
>>The "Closed" field above in the Invoice table is a bit field and in SQL7 I get "Cannot group by a bit column." error. How do I pull this off so it works? TIA.
It's "my" world. You're just living in it.