1. Поиск говнокода

    Этот поиск практически ничего не может найти! Но вы всё-таки попытайтесь, вдруг повезет.

    Найдено: 384

  2. PHP / Говнокод #26466

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    <?php
    var lastmsgid=$('.chat-msg:eq(0)',$(this).parent()).data('messageid');
    var lastmsg=$('#chat .chat-msg[data-messageid='+lastmsgid+']');
    var lastmsgscroll=lastmsg.offset().top;
    var lastscroll=$('#chat .messages').scrollTop();
    $(this).attr('disabled','disabled');var button=$(this);$.ajax({
    
              url: '<?=$baseHref;?>chat.php?more=1&user=<?=(int)$_GET['user'];?>&last=<?=(int)$last;?>',
    
              success: function(data) {
            if(data!='err'){
    data=JSON.parse(data);
    button.parent().prepend(data.messages);button.remove();fixdates();
    /*smiles*/$('#chat .messages .chat-msg div:not(.smilesadded)').each(function(){$(this).addClass('smilesadded').html(replacesmiles($(this).html()));});
    if($('#chat .messages').scrollTop()==0)$('#chat .messages').scrollTop(lastscroll-lastmsgscroll+lastmsg.offset().top);//prepend и так это делает. но не всегда
    
    } else {alert('Error');button.removeAttr('disabled');}
              },
              error:  function(xhr, str){
    	    alert('Error: ' + xhr.responseCode);
                   button.removeAttr('disabled');
              }
            });" class="btn-more button" style="margin-top:20px;margin-bottom:20px;"><?_e('Загрузить ещё');?></button><?}
    if(!isset($_GET['checknew']))$messages=array_reverse($messages);
    $user=mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT * FROM users WHERE `id`=".(int)$_GET['user']." LIMIT 1;"));
    foreach($messages as $data){
    if($yourdirection==$data['direction'])$userid=$account['id']; else $userid=(int)$_GET['user'];
    
    
    $fake=0;
    if(substr($data['text'],0,7)==':attach' && substr($data['text'],-1)==':'){$data['attachment']='../no-attach-premium.png?';if($premium)$data['attachment']=substr($data['text'],7,-1);$data['text']='';$fake=1;}
    ?>

    И сказал Господь: сойдем же и смешаем языки их, чтобы один не понимал речи другого.

    soxati, 05 Марта 2020

    Комментарии (18)
  3. Java / Говнокод #26204

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    Statement stmt = null; 
    ResultSet rs = null; 
    
    try{     
    stmt = connection.createStatement();    
    ResultSet rs = stmt.executeQuery("select * from VENDORS");   
     while(rs.next())
         {
          //тело цикла....
           }
     } 
    finally
    { 
         rs.close(); stmt.close(); 
    }

    Тимлид сказал что за такое будет руки отрывать. Что тут не так?

    mozga, 12 Декабря 2019

    Комментарии (34)
  4. PHP / Говнокод #26025

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    DBconfig.php
    <?
    function sql_connect($mysqlhost,$mysqluser,$mysqlpass,$mysqldb){
             $sql_conn=mysql_connect($mysqlhost,$mysqluser,$mysqlpass) or die("mysql_query error: " .mysql_error());
             mysql_select_db($mysqldb);
             }
    
    function sql_execute($query, $get_counter = false)
    	{
    	static $sqlquerycounter = 0;
    	if(isset($_GET['_dbg']) && isset($_GET['_sql'])){pr('['.$sqlquerycounter.'] '.$query);}
    
    	if(!$get_counter)
    		{
    		 if (!$query = mysql_query($query)) {
    			trigger_error('MySQL Error: '.mysql_error());
    		  }
    		$sqlquerycounter++;
    		return $query;
    		}
    	else {return $sqlquerycounter;}
    	}
    
    function sql_close(){
            mysql_close($sql_conn);
            }
    
    		
    ?>
    
    file.php
    
    sql_connect($_CONFIG["mysqlhost"], $_CONFIG["mysqluser"], $_CONFIG["mysqlpass"], $_CONFIG["mysqldb"]);
    $sql = sql_execute("SET NAMES UTF8");
    
    $sql = sql_execute("SELECT * FROM publications WHERE id='$_GET[id]' LIMIT 0,1");
    $res = mysql_fetch_array($sql);

    phpBidlokoder2, 11 Ноября 2019

    Комментарии (15)
  5. PHP / Говнокод #25644

    −3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    //ищем  barcode  из ws_products                                         
    if($ar_clean['product_name']){
    								$product = $ar_clean['product_name'];
    								$getServices = mysqli_query($db,"SELECT barcode FROM ws_products WHERE product_name LIKE '%$product%'");
    								$barcode = $getServices['barcode'];
    								var_dump($getServices);
    							}	
    						// Загружаем данные из в форма в перемену 
    								$username = $ar_clean['username'];
    								$product_name = $ar_clean['product_name'];
    								$date1 = $ar_clean['date1'];	
    								$date2 = $ar_clean['date2'];		
    									
    									$WHERE = ' WHERE ';	
    										
    									// Проверяем если поля заполнены		
    										if($username!=''){
    											$WHERE = $WHERE. ' AND `username` =' .$username;
    										}
    										
    										if($product_name!=''){
    											$WHERE = $WHERE. ' ` AND product_name` = ' .$product_name;
    										}
    										
    										if($date1!=''){
    											$WHERE = $WHERE.' `AND date` BETWEEN '.$date1. 'AND' .$date2 ;
    										}
    												 
    									$getServices = mysqli_query($db," SELECT * FROM `ws_purchase` '$WHERE'  ORDER BY date ASC ");
    						
    							
    										 while($Service = mysqli_fetch_assoc($getServices))
    											 { //show($Service);
    												?>
    												//вызываем данные с бд
    												<tr class="delete">
    													<td><?=$Service['id_purchase'] ?></td>
    													<td><?=$Service['other_barcode'] ?></td>
    													<td><?=$Service['username'] ?></td>
    													<td><?=$Service['other_things'] ?></td>
    													<td><?=$Service['product_name'] ?></td>
    													<td><?=$Service['price'] ?></td>
    													<td><?=$Service['date'] ?></td>
    													
    					   							</tr>
    					   						<?
    										}			 
    								}

    Привет я делаю поиск но $WHERE не работает, '".$WHERE."' так тоже не работает. Что не так я делаю?

    arts, 27 Мая 2019

    Комментарии (22)
  6. PHP / Говнокод #25570

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    <?php
        define('_SECUR_GAMES', 1);
        $rootpath = '../';
        require_once '../includes/start.php';
        require_once '../includes/function.php';
        require_once '../includes/header.php';
    if($level >0 AND $fr_id!=0)
    {
    $header='alliance';
    mysql_query("UPDATE `mesto` SET `place` = '".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($header)))))))."' WHERE `uid`=".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."");
    }
    $fr=check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($_GET['f'])))))));
    $q = mysql_query("SELECT * FROM `fractions` WHERE `id`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($fr)))))))."'");
    $f = mysql_fetch_array($q);
    $ucount = mysql_result(mysql_query("SELECT COUNT(*) FROM `fractions_users` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `fid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($f['id'])))))))."';"), 0);
    $fadm = mysql_result(mysql_query("SELECT COUNT(*) FROM `fractions_users` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `fid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($f['id'])))))))."' AND `adm`=1;"), 0);
        if($game==0 OR $level==0 OR $ban==1){
               echo "<title>Доступ закрыт!!!</title>";

    @since 2019

    eskrano, 25 Апреля 2019

    Комментарии (60)
  7. PHP / Говнокод #25551

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    <?php $connection = mysqli_connect ('localhost','root','','userlistdb'); 
           
            $per_page = 25;
            $page = 1;
    
    if (isset($_GET['page']))
            {
        $page = (int) $_GET['page'];
    }
            $total_cout_q = mysqli_query($connection, "SELECT COUNT(id_com) AS `total_count` FROM `comment`")
            $total_count = mysqli_fetch_assoc($total_cout_q);
            $total_count = $total_count['total_count'];
            
            $total_pages = ceil ($total_count/ $per_pages);
            if($page <= 1 || $page > $total_pages)
            {
                $page = 1;
            }
            $offset = ($per_page * $page)- $per_page;
            $coments = mysqli_query($connection, "SELECT *  `total_count` FROM `comment` ORDER  BY `id_com` DESC LIMIT  $offset, $per_page"); 
           $coments_exist = true;
            if(mysqli_nu,_rows($coments) <= 0 ){
               echo 'Нет коментариев';
                $coments_exist = false;
           }
        while( $result = mysqli_fetch_assoc($coments){
                
            } 
            $row = mysqli_query($connection, "SELECT * FROM `comment` ORDER  BY `id_com` DESC LIMIT 25");      
        ?>
    
         <table>
        <tr>
            <th><a href="?orderBy=username">username:</a>
            </th>
            <th>  <a href="?orderBy=email">email:</a>
            </th>
            <th>  <a href="?orderBy=recorded_date"> Date:</a>
            </th>
            <th>  <a href="?orderBy=comment">Added Date:</a>
            </th>
        </tr>
        
             <?php 
                while($row = mysql_fetch_array($result)){
        ?>
          <tr>
           <th><?php echo $result['username']; ?> </th>
           <th><?php echo $result['email']; ?> </th>
           <th><?php echo $result['Date']; ?> </th>
           <th><?php echo $result['comment']; ?> </th>
           </tr>
         </table>
    
    <?php //Страницы 
                    if ( $coments_exist = true)
                    {
                        echo '<div class="paginator">';
                    if($page > 1)
                        {
                    echo '<a href= "/Guestbook.php?page='.($page - 1).'">« предыдущий </a>'; 
                    }  if($page < $total_pages)
                        {
                    echo '<a href= "/Guestbook.php?page='.($page + 1).'"> Cледующая &eaquo; </a>';        
                    }
                        echo '</div>';
                    }
                    
                    $orderBy = array('username', 'email', 'recorded_date', 'comment');
    
    $order = 'username';
    if (isset($_GET['orderBy']) && in_array($_GET['orderBy'], $orderBy)) {
        $order = $_GET['orderBy'];
          }
             $query = 'SELECT * FROM `comment` ORDER BY '.$order;
         }
    mysqli_close();
    ?>

    Привет, тут в коде сортировка и переход по страницыам, сортировка в строки с таблицы HTML, вызываемые из MySQL, при нажиматие на username едёт сортировка по алфавиту, а затем нажимать на email или Date и сортировать по дате, но выдаёт ошыбки...

    arts, 18 Апреля 2019

    Комментарии (3)
  8. Python / Говнокод #25447

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    import sqlite3
    from bs4 import BeautifulSoup
    import requests, hashlib
    from io import open as iopen
    from urlparse import urlsplit
    
    def md5sum(filename, blocksize=65536):
    	hash = hashlib.md5()
    	with open(filename, "rb") as f:
    		for block in iter(lambda: f.read(blocksize), b""):
    			hash.update(block)
    	return hash.hexdigest()
    
    def parse_image_url(url):
    	html_doc = requests.get(url).text
    	soup = BeautifulSoup(html_doc, 'html.parser')
    	first = soup.find(class_='postContainer')
    	two = first.find_all('img')
    	requests_image(two[1].get('src'))
    
    def unic_check(file_name):
    	check_sum = md5sum(file_name)
    	if c.execute("SELECT * FROM sums WHERE sum = '%s'" % check_sum) != None:
    		cur.close()
    		conn.close()
    		return
    	else:
    		c.execute("INSERT INTO sums VALUES (%s)" % check_sum)
    		c.commit()
    		cur.close()
    		conn.close()
    		return
    
    def requests_image(file_url):
    	suffix_list = ['jpg', 'gif', 'png', 'tif', 'svg',]
    	file_name =  urlsplit(file_url)[2].split('/')[-1]
    	file_suffix = file_name.split('.')[1]
    	i = requests.get(file_url)
    	if file_suffix in suffix_list and i.status_code == requests.codes.ok:
    		with iopen(file_name, 'wb') as file:
    			file.write(i.content)
    	else:
    		return False
    	unic_check(file_name)
    
    def main():
    	Anime_types = ['http://anime.reactor.cc/tag/Anime+%D0%9D%D1%8F%D1%88%D0%B8', 'http://anime.reactor.cc/tag/Anime+Cosplay', 'http://anime.reactor.cc/tag/Anime+%D0%9A%D0%BE%D0%BC%D0%B8%D0%BA%D1%81%D1%8B', 'http://anime.reactor.cc/tag/Anime+Art']
    	global conn
    	global c
    	conn = sqlite3.connect('anime.db')
    	c = conn.cursor()
    	for x in Anime_types:
    		parse_image_url(x)
    		
    if __name__ == "__main__":
    	main()

    marataziat, 13 Марта 2019

    Комментарии (20)
  9. PHP / Говнокод #25212

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    if($form_action=="register") {
       if($coo_coo=="tootoo") {
       if($myusername) {
          if($mypassword) {
             if($mypassword==$myrepeat) {
                $uLength = strlen($myusername);
                $pLength = strlen($mypassword);
                if($uLength >= 3 && $uLength <= 30) {
                   $return_error = "";
                } else {
                   $return_error = "Username must be between 3 and 30 characters.";
                }
                if($pLength >= 3 && $pLength <= 30) {
                   $return_error = "";
                } else {
                   $return_error = "Password must be between 3 and 30 characters.";
                }
                if($return_error == "") {
                   if($db_found) {
                      $mypassword = md5($mypassword);
                      $SQL = "SELECT * FROM users WHERE username='$myusername'";
                      $result = mysql_query($SQL);
                      $num_rows = mysql_num_rows($result);
                      if($num_rows==1) {
                         $return_error = "Username already taken.";
                      } else {
                         if(!mysql_query("INSERT INTO users (id,date,ip,username,password) VALUES ('','$date','$ip','$myusername','$mypassword')")){
                            $return_error = "System error.";
                         } else {
                            $return_error = "Logged in.";
                            $_SESSION['user_session'] = $myusername;
                            header ("Location: index.php");
                         }
                      }
                   }
                }
             } else {
                $return_error = "Passwords did not match";
             }
          } else {
             $return_error = "No password was entered.";
          }
       } else {
          $return_error = "No username was entered.";
       }
       } else {
          $return_error = "Registrations are disabled.";
       }
    }

    "Сам кусок регистрации"
    Ошибка начинается с первой строки...

    MouseZver, 21 Декабря 2018

    Комментарии (31)
  10. PHP / Говнокод #25191

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    <?php
    if(isset($_GET['action']) && $_GET['action']=="add"){
            $id=intval($_GET['id']);
            if(isset($_SESSION['cart'][$id])){
            $_SESSION['cart'][$id]['quantity']++;
            }else{
    $sql_s="SELECT * FROM products
    WHERE id_product={$id}";
    $query_s=mysqli_query($sql_s);
    if(mysqli_num_rows($query_s)!=0){
    $row_s=mysqli_fetch_array($query_s);
                    $_SESSION['cart'][$row_s['id_product']]=array(
                    "quantity" => 1,
                    "price" => $row_s['price']  );
                    }else{
                    $message="This product id it's invalid!"; } } } ?>
    <h1>Product List</h1>
                    <?php
                   if(isset($message)){
                   echo "<h2>$message</h2>";  }
                   ?>
    <table>
    <tr>
                <th>Name</th>
                <th>Description</th>
                <th>Price</th>
                <th>Action</th>
    </tr>
            <?php
    $mysqli = new mysqli('……','root','……','tutorials');
    $sql = 'SELECT name,description,price, id_product FROM products'; // select from mysql
    $result = $mysqli->query($sql);  
    while($row = $result->fetch_array()){
        ?>
            <tr>
                <td><?php echo $row['name'] ?></td>
                <td><?php echo $row['description'] ?></td>
                <td><?php echo $row['price'] ?>$</td>
    <td><a href="index.php?page=products&action=add&id=<?php echo $row['id_product'] ?>">Add to cart</a></td>
            </tr>
    <?php
        }
    ?>
    </table>

    строки:
    2 - Входящую переменную так никто не проверяет. Есть функции filter_input
    3 - $_GET['id'] без проверки на существовании
    9 - mysqli_query - 1) аргумент, Идентификатор соединения. 2) сам запрос
    10 - процесс проверки num_rows глупый. Есть 0 ( ложь ), либо в остальных случаях истина.
    12 - мы выбивали из запроса id_product чтобы узнать и подставить значение как ключ $_SESSION['cart'][$row_s['id_product']] ??? Уверяю, я знаю уже ключ: $_SESSION['cart'][$id]
    30 - Глупая, тупая ошибка новичков. Постоянно на каждой логике кода, устанавливают новое соединение с бд. Нравится в постели оргия, любите много и сразу?

    Говнокодер: rita345
    https://php.ru/forum/threads/this-product-id-its-invalid.74253/

    MouseZver, 13 Декабря 2018

    Комментарии (13)
  11. SQL / Говнокод #24748

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    select * from
    (
    select case when (case when datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365 = 0 then 'Y y.,' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) as varchar(20)) + ',' end + case when (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) as varchar(20)) end) = 'Y y.,M m.' then '' else (case when datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365 = 0 then 'Y y.,' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) as varchar(20)) + ',' end + case when (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/30 - (datediff(day,date,(select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date))/365) * 12) as varchar(20)) end) end as 'Возраст', date as date1, (select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date) as date2 from Battles as P1 where (select top (1) date from Battles as P2 where P2.date > P1.date order by P2.date) is not null) as t
    union
    (select case when (case when datediff(day,date,CONVERT (date, GETDATE()))/365 = 0 then 'Y y.,' else cast((datediff(day,date,CONVERT (date, GETDATE()))/365) as varchar(20)) + ',' end + case when (datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) as varchar(20)) end) = 'Y y.,M m.' then '' else (case when datediff(day,date,CONVERT (date, GETDATE()))/365 = 0 then 'Y y.,' else cast((datediff(day,date,CONVERT (date, GETDATE()))/365) as varchar(20)) + ',' end + case when (datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) = 0 then 'M m.' else cast((datediff(day,date,CONVERT (date, GETDATE()))/30 - (datediff(day,date,CONVERT (date, GETDATE()))/365) * 12) as varchar(20)) end) end, date, CONVERT (date, GETDATE()) from Battles as T1 where (select top (1) date from Battles as T2 where T2.date > T1.date order by T2.date) is null
    );

    BDcorabli@nomer5

    akimachan, 12 Сентября 2018

    Комментарии (3)