syntax

Repeat a result row multiple times by value in row

橙三吉。 提交于 2020-01-07 03:06:17
问题 i have a question about sql query. i want to duplicate a one row with same value, The number of lines must be same with the value of quantity example i have 1 data like this Item ItemName Quantity B100 Mouse 10 but i want to be like this Item ItemName Quantity B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 B100 Mouse 10 can you help me Thanks Before 回答1: Create a numbers table and just do a CROSS JOIN with it

Executing a “sp_executesql @sqlcommand” Syntax Error

和自甴很熟 提交于 2020-01-06 19:41:15
问题 I am setting up a SQL script that creates a database from a variable name, and then takes that newly created database and restores it from a .bak file. I am having issues with some syntax in one of my commands that I am setting up, and wanted to ask if anybody could help me spot my syntax error? I am only going to paste my troubled snippet of code and its declarations, and if I am correct the issue lies in the way that I am declaring the file name paths. I have tried setting the paths to

SQL Query in Linq with HAVING SUM

我与影子孤独终老i 提交于 2020-01-06 13:04:50
问题 I have a small database example with three tables: Cities, Country and Geo_Languages (Languages spoken in the countries). Now I want to get the most spoken languages of all cities in the world with a population of at least one million people. Here is the SQL-Query: SELECT SUM(c.population) AS totalPop, g.name_en FROM cities c, country cy, geo_languages g WHERE c.country_code = cy.id AND cy.id = g.code2l GROUP BY g.name_en HAVING SUM(c.population) > 1000000 ORDER BY totalPop DESC; Here the

SQL Query in Linq with HAVING SUM

≡放荡痞女 提交于 2020-01-06 13:04:27
问题 I have a small database example with three tables: Cities, Country and Geo_Languages (Languages spoken in the countries). Now I want to get the most spoken languages of all cities in the world with a population of at least one million people. Here is the SQL-Query: SELECT SUM(c.population) AS totalPop, g.name_en FROM cities c, country cy, geo_languages g WHERE c.country_code = cy.id AND cy.id = g.code2l GROUP BY g.name_en HAVING SUM(c.population) > 1000000 ORDER BY totalPop DESC; Here the

How might one change the syntax of python list indexing?

北战南征 提交于 2020-01-06 03:21:10
问题 After asking this question, it received a comment about how you could do something like this: >>> def a(n): print(n) return a >>> b = a(3)(4)(5) 3 4 5 Is it possible to use this or similar concepts to make it possible to index lists like my_list(n) instead of my_list[n] ? 回答1: You'd have to use a custom class, and give it a __call__ special method to make it callable. A subclass of list would do nicely here: class CallableList(list): def __call__(self, item): return self[item] You cannot use

Scala - semicolon inconsistency

牧云@^-^@ 提交于 2020-01-05 20:22:39
问题 I have this very simple code (scala-2.10): import scala.io.Source object Test2 { def main(args: Array[String]): Unit = { for(line <- Source.fromFile("/Users/alexei/words.txt", "utf-8").getLines()) { println(line) } } } I get this error message when compiling: Test2.scala:3: error: ';' expected but 'object' found. object Test2 { ^ one error found I am terribly confused when to use semicolons or not. I have other code similar to this and it has no issues compiling without any semicolons what so

Scala - semicolon inconsistency

北城以北 提交于 2020-01-05 20:22:26
问题 I have this very simple code (scala-2.10): import scala.io.Source object Test2 { def main(args: Array[String]): Unit = { for(line <- Source.fromFile("/Users/alexei/words.txt", "utf-8").getLines()) { println(line) } } } I get this error message when compiling: Test2.scala:3: error: ';' expected but 'object' found. object Test2 { ^ one error found I am terribly confused when to use semicolons or not. I have other code similar to this and it has no issues compiling without any semicolons what so

What do angled brackets mean when used in member name in C#?

南笙酒味 提交于 2020-01-05 15:15:32
问题 I was browsing through sources of PresentationCore.dll using DotPeek when I found this: // Type: MS.Internal.TtfDelta.CMAP_HEADER // Assembly: PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // Assembly location: D:\Windows\Microsoft.NET\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace MS.Internal.TtfDelta { [NativeCppClass]

Encapsulating data definitions in Haskell

和自甴很熟 提交于 2020-01-05 09:19:11
问题 I am trying to define a data type using other data types like this: data A = Something String | SomethingElse Int data B = Another B | YetAnother A data C = A | B x :: [ C ] x = [ YetAnother (SomethingElse 0), Something "Hello World" ] But this is giving me an error saying that I cannot have a type A when expecting a type B. Why is this? 回答1: You're missing the data constructors for C . data A = Something String | SomethingElse Int data B = Another B | YetAnother A data C = C0 A | C1 B x :: [

Multiple assignment using a Map's value instead of a variable with Groovy

独自空忆成欢 提交于 2020-01-05 08:38:23
问题 In Groovy , I have a function that returns a triple. I'd like to: put the first value returned in a Map for an arbitrary key and assign the two other values to variables. I can do: Map m = [:] (day, month, year) = "12 February 2014".split(" "); m["day"] = day; But I would like to get rid of the variable day , like this: Map m = [:] (m["day"], month, year) = "12 February 2014".split(" "); For some reason it seems to be not possible. This is what the compiler alerts me about: org.codehaus