Ich habe eine Tsql-Abfrage, die Berechnungen für Prozentsätze, und es berechnet gut, wenn das Ergebnis> 1 ist, aber 0, wenn es kleiner als 1 ist. Meine Berechnung ist so :TSQL-Abfrage mit Berechnung nicht zurück Wert kleiner als 1
create table dbo.#temptable (
total_sold int null,
#_in_ny int null,
percent_in_ny decimal(18,2)null
) on [primary]
insert into dbo.#temptable
select count(t.booknum) as totalsold, t.#_in_ny, 100 * t.#_in_ny/count(t.booknum)
from mytable t
Das gibt mir:
total ny sales %sales in ny
650 4 0 ---- this should show up as 0.61 since 4 is .61% of 650
tut mit einem float in der Konstante sql Server-Server, um die Dezimaldivision zu tun? –