Mistři v programování na #hovnokod

Jak se zjišťuje při vyúčtování, zda se jedná o zahraniční subjekt? Tomu se říká dokonalý návrh databáze

SELECT * FROM t_slevy_poznamky WHERE id_akce = $ident AND (
LOWER(poznamka) = LOWER('Slovenský subjekt') 
OR 
LOWER(poznamka) = LOWER('Zahraniční subjekt mimo SR ale v EU')
)

Vít Ledvinka,

SELECT
    CAST(
        '0' AS VARCHAR(256)
    ) AS "HourId",
    CAST(
        '00' AS VARCHAR(256)
    ) AS "HourId_Sort"
UNION ALL SELECT
    '1',
    '01'
UNION ALL SELECT
    '2',
    '02'
UNION ALL SELECT
    '3',
    '03'
UNION ALL SELECT
    '4',
    '04'
UNION ALL SELECT
    '5',
    '05'
UNION ALL SELECT
    '6',
    '06'
UNION ALL SELECT
    '7',
    '07'
UNION ALL SELECT
    '8',
    '08'
UNION ALL SELECT
    '9',
    '09'
UNION ALL SELECT
    '10',
    '10'
UNION ALL SELECT
    '11',
    '11'
UNION ALL SELECT
    '12',
    '12'
UNION ALL SELECT
    '13',
    '13'
UNION ALL SELECT
    '14',
    '14'
UNION ALL SELECT
    '15',
    '15'
UNION ALL SELECT
    '16',
    '16'
UNION ALL SELECT
    '17',
    '17'
UNION ALL SELECT
    '18',
    '18'
UNION ALL SELECT
    '19',
    '19'
UNION ALL SELECT
    '20',
    '20'
UNION ALL SELECT
    '21',
    '21'
UNION ALL SELECT
    '22',
    '22'
UNION ALL SELECT
    '23',
    '23';

Anonymous,

Jeden pěkný GROUP BY v kódu, fakt lahoda. Tečky jsem tam dal já, nemusím zveřejňovat všechno.

SELECT .....................
GROUP BY case when ((SU>=0) AND (SU<111)) OR (SU is NULL) then 0 
                  when SU in (111,112)          then 111  
                  when SU>112                   then 113  
                  when SU=-5                    then -5
                  when SU=-3                    then -3
             end,
 case when ((SU>=0) AND (SU<111)) OR (SU is NULL) then 110 
            when SU in (111,112)          then 112
            when SU>112                   then 999
            when SU=-5                    then -5
            when SU=-3                    then -3
       end,
 case when ((SU>=0) AND (SU<111)) OR (SU is NULL) then 'pro smlouvy.....'
               when SU in (111,112)          then 'pro smlouvy se .........'
               when SU>112                   then 'pro smlouvy se SÚ V....................'
               when SU=-5                    then 'pro smlouvy s BSP'
               when SU=-3                    then 'pro úvěry .............'
          end,
  case when ((SU>=0) AND (SU<111)) OR (SU is NULL) then 2  --plati pro min. KodSmlUjednani
                  when SU in (111,112)          then 3  
                  when SU>112                   then 4  
                  when SU=-5                    then 5
                  when SU=-3                    then 1
    end
 order by Poradi


Anonymous,

Ať žije operátor IN!

SELECT * FROM clanky WHERE ((Zdroj='142')or(Zdroj='48')or(Zdroj='95')or(Zdroj='96')or(Zdroj='97')or(Zdroj='98')or(Zdroj='99')or(Zdroj='100')or(Zdroj='101')) ORDER BY Pridano DESC LIMIT $limmit

Jiří Vích,

create function is_numeric (
	@a varchar(100)
) returns int as begin
	declare @retval int
	set @a = replace(@a, '0', '')
	set @a = replace(@a, '1', '')
	set @a = replace(@a, '2', '')
	set @a = replace(@a, '3', '')
	set @a = replace(@a, '4', '')
	set @a = replace(@a, '5', '')
	set @a = replace(@a, '6', '')
	set @a = replace(@a, '7', '')
	set @a = replace(@a, '8', '')
	set @a = replace(@a, '9', '')
	set @a = replace(@a, '.', '')
	if len(rtrim(ltrim(@a))) > 0 set @retval = 0
	else set @retval = 1
	return @retval
end

HovnoKod,