我最近了解了GROUPING SETS,CUBE和ROLLUP,用于在sql server中定义多个分组集.
我问的是在什么情况下我们使用这些功能?使用它们有什么好处和好处?
SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS numorders
FROM Sales.Orders
GROUP BY GROUPING SETS ( ( shipperid, YEAR(shippeddate) ), ( shipperid ), ( YEAR(shippeddate) ), ( ) );
SELECT shipperid, YEAR(shippeddate) AS shipyear, COUNT(*) AS numorders
FROM Sales.Orders
GROUP BY CUBE( shipperid, YEAR(shippeddate) );
SELECT shipcountry, shipregion, shipcity, COUNT(*) AS numorders
FROM Sales.Orders
GROUP BY ROLLUP( shipcountry, shipregion, shipcity );
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Swing类创建网格UI(5*5).我尝试了一个嵌套循环,并动态地将jPanel添加到jFrame.我还尝试在用户点击并删除时更改每个jPanel的背景颜色.但是使用我的代码,每个单元格之间存在巨大差距,我无法使拖动事件起作用.
public class clsCanvasPanel extends JPanel {
private static final int intRows = 5;
private static final int intCols = 5;
private List<JPanel> jpllist = new ArrayList<JPanel>();
public clsCanvasPanel() {
/*
*
* Add eventListener to individual JPanel within CanvasPanel
*
*
* TODO :
* 1) mousePressed --> update Temperature and HeatConstant of clsElement Class
* 2) start a new thread and
* 3) call clsElement.run() method
*
*
* Right Now : it updates the colours of the …Run Code Online (Sandbox Code Playgroud) 我有这个错误,填充JList后,我尝试检索所选项的值.但是当我这样做时,它会被调用两次.
这是我的代码:
public CaveAdventureUI(CaveGame game) {
initComponents();
playerCarryItemModel = new DefaultListModel();
caveCarryItemModel = new DefaultListModel();
this.caveGame = game;
this.world = game.getCaveWorld();
listSelectionModel = this.jListCaveCarryItems.getSelectionModel();
listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.listSelectionModel.addListSelectionListener( new SharedListSelectionHandler());
//for debug purpose,see the world grid in console
game.drawCaves();
//new JComboBox(Mood.values());
createGridQuarePanels();
//world.startGame(GameLevel.Beginner);
update();
}
private class SharedListSelectionHandler implements ListSelectionListener {
public void valueChanged(ListSelectionEvent listSelectionEvent) {
ListSelectionModel lsm = (ListSelectionModel)listSelectionEvent.getSource();
if (!lsm.isSelectionEmpty()) {
Occupant opt = mapOccupants.get(Integer.toString(jListCaveCarryItems.getSelectedIndex()));
System.out.println("selected index :" +jListCaveCarryItems.getSelectedIndex() +"[["+opt.getName()+"]]");
}
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,当我在jList:jListCaveCarryItems上进行选择时,它会触发SharedListSelectionHandler类.但是,当我单击JList时,它会打印出两次所选的值.
任何人都可以帮我搞清楚吗?
感谢和问候,
我正在学习地图数据结构知道,我无法理解entrySet() Set<Map.Entry<K,V>>地图界面内部.这应该是嵌套的自引用吗?作为参考,这是java.util.Map<K,V>界面定义的摘录:
public interface Map<K,V> {
Set<Map.Entry<K,V>> entrySet();
...
}
Run Code Online (Sandbox Code Playgroud) 我正在处理一个tsql项目,并且我已经注意到现有代码使用的语法是我以前从未见过的。他们在数据库名称前面加了一个美元符号,以表示完全合格的地址。
这是一个例子:
SELECT c.AccountCode, FROM **[$(SmartAdmin)]**.dbo.Customers c
Run Code Online (Sandbox Code Playgroud)

如果我将数据库名称重命名为SmartAdmin.dbo.Customers,Visual Studio会抛出错误消息,提示“包含对对象的未解析引用”。
这似乎是与Visual Studio相关的事情,任何人都可以解释一下这是什么以及是否可以删除它。
请查看随附的屏幕截图,最后一个来自项目解决方案文件。


我正在编写一个正则表达式来从 html 字符串中提取类似#Question1#或 的短语#Question125#
患者姓名#Question1#,患者患有#Question2#,患者性别为#Question3#,患者上个月有#Question4#饮酒。他的出生日期是#Question5#
表达式的前半部分很简单#Question,但我还需要匹配一系列未指定长度的数字,并且整个字符串以#结尾。
一旦找到匹配的短语,如何从字符串中仅提取数字?比如#Question312#,我只想得到312?
有什么建议吗?
我有以下while循环,如果我在while循环条件中放入this.boatTripsList.iterator().hasNext(),则抛出错误.当我创建迭代器然后放入while循环条件时,它将工作.为什么是这样?感谢和问候.(第二个版本抛出错误)
public Journey(List<BoatTrip> trips) {
this.boatTripsList = new LinkedList<BoatTrip>();
Iterator<BoatTrip> iterator = trips.iterator();
//add the given boat trips to the boattrips list
while (iterator.hasNext()) {
BoatTrip thistrip = iterator.next();
this.boatTripsList.add(thistrip);
}
}
public Journey(List<BoatTrip> trips) {
this.boatTripsList = new LinkedList<BoatTrip>();
//add the given boat trips to the boattrips list
while (trips.iterator().hasNext()) {
BoatTrip thistrip = iterator.next();
this.boatTripsList.add(thistrip);
}
}
Run Code Online (Sandbox Code Playgroud)