在不同日期找到大于和的变量10x的和

时间:2016-06-10 16:58:00

标签: sql-server

我有一个数据库,用于记录收音机上播放的每首歌曲的时间戳。我试图找到自16/1/16以来增加了10倍的歌曲,我跑了这个:

SELECT SONG_ID
FROM StationPlays
WHERE StationPlays.DATE > '2016-06-01' AND SONG_ID IN 
(
  SELECT SONG_ID
  FROM StationPlays
  WHERE StationPlays.DATE < '2016-06-01'
  GROUP BY SONG_ID
  HAVING SUM(SPINS) < 1000
)
GROUP BY SONG_ID
HAVING SUM(SPINS) > 10000

有没有办法以编程方式执行此操作,我可以将1000设置为变量并使用10 * Variable来查找在过去x天内增加10倍(或20倍或更多)的所有歌曲?

1 个答案:

答案 0 :(得分:2)

我会尝试这样的事情:

<?php
session_start();
$conb = mysqli_connect("127.0.0.1","root","","demo");
$sellmail = $_SESSION['sellermaill'];
$buyermail = $_POST['email'];
$bid = $_POST["bid"];
$title = $_SESSION["Titleofp"];
echo"$sellmail";
echo"$buyermail";
echo"$bid";
echo"$title";
$mysqlbuy = "INSERT INTO buyer (Seller Mail,Buyer Mail,Bid,Product Title) VALUES ('$sellmail','$buyermail','$bid','$title')";
$mysqlsellq = mysqli_query($conb,$mysqlbuy);
if(!$mysqlsellq)
    {echo "Your Bid has not been saved ";}
else echo "Your Bid has been Saved ";

?>