结果中有2个列的聚合

时间:2017-04-30 12:30:47

标签: mysql sql aggregate mysql-workbench star-schema

我正在尝试在我的结果表中聚合两列,但我无法理解它...我有一个星型模式和以下查询:

nvidia@tegra-ubuntu:~/code/VulkanTools/demos$ gcc cube.c
/tmp/ccbouT30.o: In function `vec3_len':
cube.c:(.text+0x258): undefined reference to `sqrtf'
/tmp/ccbouT30.o: In function `mat4x4_rotate':
cube.c:(.text+0xa38): undefined reference to `sinf'
cube.c:(.text+0xa44): undefined reference to `cosf'
/tmp/ccbouT30.o: In function `mat4x4_perspective':
cube.c:(.text+0xbe4): undefined reference to `tan'
/tmp/ccbouT30.o: In function `demo_flush_init_cmd':
cube.c:(.text+0x15ac): undefined reference to `vkEndCommandBuffer'
cube.c:(.text+0x160c): undefined reference to `vkCreateFence'
cube.c:(.text+0x169c): undefined reference to `vkQueueSubmit'
cube.c:(.text+0x16f0): undefined reference to `vkWaitForFences'
cube.c:(.text+0x174c): undefined reference to `vkFreeCommandBuffers'
cube.c:(.text+0x1760): undefined reference to `vkDestroyFence'
/tmp/ccbouT30.o: In function `demo_set_image_layout':
cube.c:(.text+0x1940): undefined reference to `vkCmdPipelineBarrier'
/tmp/ccbouT30.o: In function `demo_draw_build_cmd':
cube.c:(.text+0x1a78): undefined reference to `vkBeginCommandBuffer'
cube.c:(.text+0x1ac0): undefined reference to `vkCmdBeginRenderPass'
cube.c:(.text+0x1ad8): undefined reference to `vkCmdBindPipeline'
cube.c:(.text+0x1b30): undefined reference to `vkCmdBindDescriptorSets'
cube.c:(.text+0x1b84): undefined reference to `vkCmdSetViewport'
cube.c:(.text+0x1bcc): undefined reference to `vkCmdSetScissor'
cube.c:(.text+0x1be4): undefined reference to `vkCmdDraw'
cube.c:(.text+0x1bec): undefined reference to `vkCmdEndRenderPass'
cube.c:(.text+0x1cc8): undefined reference to `vkCmdPipelineBarrier'
cube.c:(.text+0x1cd0): undefined reference to `vkEndCommandBuffer'
/tmp/ccbouT30.o: In function `demo_build_image_ownership_cmd':
cube.c:(.text+0x1dac): undefined reference to `vkBeginCommandBuffer'
cube.c:(.text+0x1ec8): undefined reference to `vkCmdPipelineBarrier'
cube.c:(.text+0x1ef0): undefined reference to `vkEndCommandBuffer'
/tmp/ccbouT30.o: In function `demo_update_data_buffer':
cube.c:(.text+0x204c): undefined reference to `vkWaitForFences'
cube.c:(.text+0x20a0): undefined reference to `vkMapMemory'
cube.c:(.text+0x2124): undefined reference to `vkUnmapMemory'
/tmp/ccbouT30.o: In function `demo_draw':
cube.c:(.text+0x2778): undefined reference to `vkWaitForFences'
cube.c:(.text+0x27b0): undefined reference to `vkResetFences'
cube.c:(.text+0x29cc): undefined reference to `vkResetFences'
cube.c:(.text+0x2a18): undefined reference to `vkQueueSubmit'
cube.c:(.text+0x2b0c): undefined reference to `vkQueueSubmit'
/tmp/ccbouT30.o: In function `demo_prepare_buffers':
cube.c:(.text+0x3388): undefined reference to `vkWaitForFences'
cube.c:(.text+0x364c): undefined reference to `vkCreateImageView'
cube.c:(.text+0x36c4): undefined reference to `vkCreateFence'
/tmp/ccbouT30.o: In function `demo_prepare_depth':
cube.c:(.text+0x391c): undefined reference to `vkCreateImage'
cube.c:(.text+0x3974): undefined reference to `vkGetImageMemoryRequirements'
cube.c:(.text+0x3a44): undefined reference to `vkAllocateMemory'
cube.c:(.text+0x3aa0): undefined reference to `vkBindImageMemory'
cube.c:(.text+0x3b08): undefined reference to `vkCreateImageView'
/tmp/ccbouT30.o: In function `demo_prepare_texture_image':
cube.c:(.text+0x3efc): undefined reference to `vkCreateImage'
cube.c:(.text+0x3f54): undefined reference to `vkGetImageMemoryRequirements'
cube.c:(.text+0x3ff4): undefined reference to `vkAllocateMemory'
cube.c:(.text+0x4050): undefined reference to `vkBindImageMemory'
cube.c:(.text+0x40d0): undefined reference to `vkGetImageSubresourceLayout'
cube.c:(.text+0x4104): undefined reference to `vkMapMemory'
cube.c:(.text+0x41b4): undefined reference to `vkUnmapMemory'
/tmp/ccbouT30.o: In function `demo_destroy_texture_image':
cube.c:(.text+0x421c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x423c): undefined reference to `vkDestroyImage'
/tmp/ccbouT30.o: In function `demo_prepare_textures':
cube.c:(.text+0x4288): undefined reference to `vkGetPhysicalDeviceFormatProperties'
cube.c:(.text+0x4550): undefined reference to `vkCmdCopyImage'
cube.c:(.text+0x46e0): undefined reference to `vkCreateSampler'
cube.c:(.text+0x477c): undefined reference to `vkCreateImageView'
/tmp/ccbouT30.o: In function `demo_prepare_cube_data_buffers':
cube.c:(.text+0x4a68): undefined reference to `vkCreateBuffer'
cube.c:(.text+0x4adc): undefined reference to `vkGetBufferMemoryRequirements'
cube.c:(.text+0x4b88): undefined reference to `vkAllocateMemory'
cube.c:(.text+0x4c08): undefined reference to `vkMapMemory'
cube.c:(.text+0x4c94): undefined reference to `vkUnmapMemory'
cube.c:(.text+0x4cf8): undefined reference to `vkBindBufferMemory'
/tmp/ccbouT30.o: In function `demo_prepare_descriptor_layout':
cube.c:(.text+0x4e10): undefined reference to `vkCreateDescriptorSetLayout'
cube.c:(.text+0x4ea0): undefined reference to `vkCreatePipelineLayout'
/tmp/ccbouT30.o: In function `demo_prepare_render_pass':
cube.c:(.text+0x5058): undefined reference to `vkCreateRenderPass'
/tmp/ccbouT30.o: In function `demo_prepare_shader_module':
cube.c:(.text+0x511c): undefined reference to `vkCreateShaderModule'
/tmp/ccbouT30.o: In function `demo_prepare_pipeline':
cube.c:(.text+0x56b0): undefined reference to `vkCreatePipelineCache'
cube.c:(.text+0x5778): undefined reference to `vkCreateGraphicsPipelines'
cube.c:(.text+0x57cc): undefined reference to `vkDestroyShaderModule'
cube.c:(.text+0x57ec): undefined reference to `vkDestroyShaderModule'
/tmp/ccbouT30.o: In function `demo_prepare_descriptor_pool':
cube.c:(.text+0x58bc): undefined reference to `vkCreateDescriptorPool'
/tmp/ccbouT30.o: In function `demo_prepare_descriptor_set':
cube.c:(.text+0x5b00): undefined reference to `vkAllocateDescriptorSets'
cube.c:(.text+0x5bcc): undefined reference to `vkUpdateDescriptorSets'
/tmp/ccbouT30.o: In function `demo_prepare_framebuffers':
cube.c:(.text+0x5d1c): undefined reference to `vkCreateFramebuffer'
/tmp/ccbouT30.o: In function `demo_prepare':
cube.c:(.text+0x5e00): undefined reference to `vkCreateCommandPool'
cube.c:(.text+0x5e7c): undefined reference to `vkAllocateCommandBuffers'
cube.c:(.text+0x5ed4): undefined reference to `vkBeginCommandBuffer'
cube.c:(.text+0x5f88): undefined reference to `vkAllocateCommandBuffers'
cube.c:(.text+0x6030): undefined reference to `vkCreateCommandPool'
cube.c:(.text+0x60d0): undefined reference to `vkAllocateCommandBuffers'
/tmp/ccbouT30.o: In function `demo_cleanup':
cube.c:(.text+0x623c): undefined reference to `vkDeviceWaitIdle'
cube.c:(.text+0x627c): undefined reference to `vkWaitForFences'
cube.c:(.text+0x62ac): undefined reference to `vkDestroyFence'
cube.c:(.text+0x62d4): undefined reference to `vkDestroySemaphore'
cube.c:(.text+0x62fc): undefined reference to `vkDestroySemaphore'
cube.c:(.text+0x6334): undefined reference to `vkDestroySemaphore'
cube.c:(.text+0x6390): undefined reference to `vkDestroyFramebuffer'
cube.c:(.text+0x63d0): undefined reference to `vkDestroyDescriptorPool'
cube.c:(.text+0x63f0): undefined reference to `vkDestroyPipeline'
cube.c:(.text+0x6410): undefined reference to `vkDestroyPipelineCache'
cube.c:(.text+0x6430): undefined reference to `vkDestroyRenderPass'
cube.c:(.text+0x6450): undefined reference to `vkDestroyPipelineLayout'
cube.c:(.text+0x6470): undefined reference to `vkDestroyDescriptorSetLayout'
cube.c:(.text+0x64b4): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x64f0): undefined reference to `vkDestroyImage'
cube.c:(.text+0x652c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6568): undefined reference to `vkDestroySampler'
cube.c:(.text+0x65c8): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x65e8): undefined reference to `vkDestroyImage'
cube.c:(.text+0x6608): undefined reference to `vkFreeMemory'
cube.c:(.text+0x664c): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6694): undefined reference to `vkFreeCommandBuffers'
cube.c:(.text+0x66d0): undefined reference to `vkDestroyBuffer'
cube.c:(.text+0x670c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6748): undefined reference to `vkDestroyFence'
cube.c:(.text+0x67a0): undefined reference to `vkDestroyCommandPool'
cube.c:(.text+0x67d0): undefined reference to `vkDestroyCommandPool'
cube.c:(.text+0x67dc): undefined reference to `vkDeviceWaitIdle'
cube.c:(.text+0x67ec): undefined reference to `vkDestroyDevice'
cube.c:(.text+0x6844): undefined reference to `vkDestroySurfaceKHR'
cube.c:(.text+0x6854): undefined reference to `vkDestroyInstance'
/tmp/ccbouT30.o: In function `demo_resize':
cube.c:(.text+0x6898): undefined reference to `vkDeviceWaitIdle'
cube.c:(.text+0x68dc): undefined reference to `vkDestroyFramebuffer'
cube.c:(.text+0x691c): undefined reference to `vkDestroyDescriptorPool'
cube.c:(.text+0x693c): undefined reference to `vkDestroyPipeline'
cube.c:(.text+0x695c): undefined reference to `vkDestroyPipelineCache'
cube.c:(.text+0x697c): undefined reference to `vkDestroyRenderPass'
cube.c:(.text+0x699c): undefined reference to `vkDestroyPipelineLayout'
cube.c:(.text+0x69bc): undefined reference to `vkDestroyDescriptorSetLayout'
cube.c:(.text+0x6a00): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6a3c): undefined reference to `vkDestroyImage'
cube.c:(.text+0x6a78): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6ab4): undefined reference to `vkDestroySampler'
cube.c:(.text+0x6aec): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6b0c): undefined reference to `vkDestroyImage'
cube.c:(.text+0x6b2c): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6b70): undefined reference to `vkDestroyImageView'
cube.c:(.text+0x6bb8): undefined reference to `vkFreeCommandBuffers'
cube.c:(.text+0x6bf4): undefined reference to `vkDestroyBuffer'
cube.c:(.text+0x6c30): undefined reference to `vkFreeMemory'
cube.c:(.text+0x6c6c): undefined reference to `vkDestroyFence'
cube.c:(.text+0x6cac): undefined reference to `vkDestroyCommandPool'
cube.c:(.text+0x6cdc): undefined reference to `vkDestroyCommandPool'
/tmp/ccbouT30.o: In function `demo_init_vk':
cube.c:(.text+0x6ea4): undefined reference to `vkEnumerateInstanceLayerProperties'
cube.c:(.text+0x6f18): undefined reference to `vkEnumerateInstanceLayerProperties'
cube.c:(.text+0x7084): undefined reference to `vkEnumerateInstanceExtensionProperties'
cube.c:(.text+0x70f8): undefined reference to `vkEnumerateInstanceExtensionProperties'
cube.c:(.text+0x73d0): undefined reference to `vkCreateInstance'
cube.c:(.text+0x7478): undefined reference to `vkEnumeratePhysicalDevices'
cube.c:(.text+0x74ec): undefined reference to `vkEnumeratePhysicalDevices'
cube.c:(.text+0x7578): undefined reference to `vkEnumerateDeviceExtensionProperties'
cube.c:(.text+0x761c): undefined reference to `vkEnumerateDeviceExtensionProperties'
cube.c:(.text+0x7998): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x79c0): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7a50): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7b94): undefined reference to `vkGetPhysicalDeviceProperties'
cube.c:(.text+0x7bb4): undefined reference to `vkGetPhysicalDeviceQueueFamilyProperties'
cube.c:(.text+0x7c38): undefined reference to `vkGetPhysicalDeviceQueueFamilyProperties'
cube.c:(.text+0x7c48): undefined reference to `vkGetPhysicalDeviceFeatures'
cube.c:(.text+0x7c64): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7cc0): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7d1c): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7d78): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x7dd4): undefined reference to `vkGetInstanceProcAddr'
/tmp/ccbouT30.o: In function `demo_create_device':
cube.c:(.text+0x7f54): undefined reference to `vkCreateDevice'
/tmp/ccbouT30.o: In function `demo_init_vk_swapchain':
cube.c:(.text+0x823c): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x82e4): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x838c): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x8434): undefined reference to `vkGetInstanceProcAddr'
cube.c:(.text+0x84dc): undefined reference to `vkGetInstanceProcAddr'
/tmp/ccbouT30.o:cube.c:(.text+0x8594): more undefined references to `vkGetInstanceProcAddr' follow
/tmp/ccbouT30.o: In function `demo_init_vk_swapchain':
cube.c:(.text+0x86dc): undefined reference to `vkGetDeviceQueue'
cube.c:(.text+0x8730): undefined reference to `vkGetDeviceQueue'
cube.c:(.text+0x8908): undefined reference to `vkCreateFence'
cube.c:(.text+0x8970): undefined reference to `vkCreateSemaphore'
cube.c:(.text+0x89d8): undefined reference to `vkCreateSemaphore'
cube.c:(.text+0x8a50): undefined reference to `vkCreateSemaphore'
cube.c:(.text+0x8ac0): undefined reference to `vkGetPhysicalDeviceMemoryProperties'
collect2: error: ld returned 1 exit status
nvidia@tegra-ubuntu:~/code/VulkanTools/demos$

结果表会以这种方式返回正确的结果:

enter image description here

这是架构:

enter image description here

我无法找到一种方法来根据SubCategory聚合它...所以它看起来像住宿,660,1004390

在group by子句中使用汇总尝试它,但是只聚合第2列,第3列总是返回“NULL”

你有什么想法吗?非常感谢帮助!

2 个答案:

答案 0 :(得分:0)

business移除GROUP BY。此外,从不FROM子句中使用逗号。 始终使用正确的JOIN语法:

select u.SubCategory, count(i.NACE_ID)
from industry_facts join i
     1und1 u
     on u.NACE_ID = i.NACE_ID join
     statistics_2016 s 
     on s.Stat_ID = i.Stat_ID
group by u.SubCategory ASC;

如果您想要这些商家,则可以使用group_concat(s.businesses)SELECT中的group_concat(distinct s.businesses)

答案 1 :(得分:0)

尝试使用此代码:

   select 1und1.SubCategory,count(industry_facts.NACE_ID), statistics_2016.businesses 
    from industry_facts inner join 1und1
    on industry_facts.NACE_ID=1und1.NACE_ID
    join statistics_2016
    on statistics_2016.Stat_ID = industry_facts.Stat_ID
    group by 1und1.SubCategory,statistics_2016.businesses
    order by 1und1.SubCategory